Fabulous PHP frameworks: CakePHP

CakePHP combines easy installation with command-line tools that jump-start development, striking a good balance between small and large

CakePHP, a product of the Cake Foundation, successfully walks the line between large frameworks (such as Zend) and small frameworks (such as Lithium). CakePHP's documentation claims that the framework requires no configuration. The CakePHP website gushes, "Set up the database and let the magic begin." This is a bit colorful, but not too far from the truth. The framework also features excellent command-line tools that dramatically reduce the time required to build an application. The current stable release, Version 1.2.9, requires at least PHP 4.3.2. 

As with other frameworks, CakePHP defines a strict directory structure, with equally strict rules regarding which files go in which subdirectory. This is referred to as "convention over configuration" and is in keeping with the framework's "no configuration" claims. You don't modify a configuration file to specify the location and function of files, classes, or methods; rather, you place specific elements in predetermined locations within the project. For example, all the library code is kept in the /cake subfolder of an application directory, and documentation expressly states that you must swear an oath not to modify the files in that directory. The directory structure also distinguishes between first-party libraries and third-party libraries, which helps you keep your corporate libraries separate from those acquired from the outside.

The convention over configuration principle carries through to framework entity names. Model classnames must be singular and camel-cased. For example, a model that manages music albums might be represented by a class named MusicAlbum. Table names corresponding to CakePHP models are plural and underscored, so our table for the MusicAlbum model would be music_albums. CakePHP even provides a utility library for pluralizing names to assist in the process.

CakePHP Cake and Bake
CakePHP has a command-line script utility -- called Cake -- that runs "shells," or a script for building or maintaining a CakePHP application. For example, CakePHP provides a built-in shell called Bake. If you've already defined the database for your application, the Bake shell will create model classes and method scaffolding for that database. If requested, it will even construct unit tests for the model. Should you wish to create your own shells, documentation describes the process. Once you've written a shell, store it in a specific directory, and it is immediately available through the Cake script.

CakePHP's fauna consists of more than models, views, and controllers. The system lets you define components, which are classes that assist controllers with additional functionality. Because a component is implemented as an independent class, you can use the component system to share logic among different controllers. A "helper" is analogous to a component, but helpers let you share logic among views. And a "behavior" lets you share logic among models. CakePHP also recognizes an entity called a DataSource, which is a class for processing data drawn from origins other than databases. Finally, CakePHP lets you bundle models, controllers, and views into a plug-in, so you can package functionality into a module that is dropped wholesale into an application, ready for use.

Test Center Scorecard
  40% 25% 25% 10%  
CakePHP 1.2.9 9 9 8 9


Very Good

1 2 Page 1
Page 1 of 2
How to choose a low-code development platform