[UPHPU] cakephp questions
Kevin Carter
email.bdr at gmail.com
Fri Jan 16 01:07:48 MST 2009
Brandon Stout wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> First a couple questions now that we had a meeting about cakephp. When
> I looked at it a few months ago, I was surprised to see that they were
> still writing their product for PHP 4, and the documentation stated they
> did not plan to support PHP 5 since 'most people are still using PHP 4'
> (loosely quoted). Since PHP 5 has been out a few years, I thought that
> was pretty lame, and went with Kohana ( http://kohanaphp.com ). Since
> then, Mac Newbold mentioned to me that cakephp had a beta product that
> does support PHP 5. Now my questions:
>
> * If it supports both PHP 4 and 5, does it take advantage sufficiently
> of PHP 5 OOP?
CakePHP is heavily object based. (as object based as you can be in php).
> * Is there a lot of bloat since you have to sometimes do the same thing
> two different ways: the PHP 4 way and the PHP 5 way? It seems that an
> application should support one or the other, not both at the same time
> for that reason.
The main difference between objects in php4 and php5 is that they
changed the way constructor/destructors work (5 has __construct and
__destruct) and added visibility(pubilc, private, protected) in 5. In
cake all the objects implement the php 5 constructors and destructors,
then all classes inherit from a base class that handles making sure
those are properly called in php 4. Visibility is handled inside of cake
by a naming convention. Normal methods are public, methods that start
with a _ are protected and methods that start with __ are private. Now
the visibility isn't necessarily enforced this way (there are a few
places where it is), but it also makes finding and converting those
functions to php5 style a little easier. PHP 5 also adds support for
overloading methods on objects. This is something cake uses. So this is
one area where they've had to write more code to make this work in 4,
but that code only loads if your using PHP 4. PHP 5 also adds object
support for things like abstract class, interfaces, class constants,
etc., but those aren't really a necessary thing for it to be doing
objects. There's a few other small places where the inadequacies of php
4 have to be handled, but they are fairly minor.
In the end cakephp is designed for php 5 and if anything a little more
code has to be loaded to support 4 if your using it. It is possible to
write you cakephp in php 5 style classes and have it work just fine. The
cakephp 2 release is slated to drop support for php 4, but that release
is a little ways off.
> * Are there any Kohana PHP users out there that prefer one over the
> other, and if so, what?
>
> Brandon Stout
> Stout Hosting LLC
-Kevin-
More information about the UPHPU
mailing list