CakePHP impressions post
As much fun as maintaining my own psuedo framework is, and hacking away on our own framework/CMS at work, I\'ve decided its time to try out CakePHP, one of the many php frameworks out there, to update a website I built three-plus years ago for my dad.
I chose CakePHP for a number of reasons, chiefly it works on both PHP4 and PHP5, doesn\'t seem to have extraneous fluff attached to it, or require a make-like system to setup a web app. Its also really well documented, and out-of-the-box it gives you very descriptive error messages.
Here are my first impressions from 2 hours of setting it up to pull news stories out of a database:
- Helpful and plentyful documentation is on the wiki and online manual.
- I like the organization of the code, particularly the secure production layout that places only only files required by http visitors in your webroot.
- The naming convention enforces good code organization, something I struggle with when writing up code.
- As I mentioned earlier, very helpful messages pop up as you setup your models, controllers, and views.
- For some unknown reason, I tried to use Adodb for database access, since its listed as supported. I checked out the latest subversion trunk and ran into a bug in how it handles limit statements. It doesn\'t really work unless you go in and update the selectLimit function in libs/model/db/dbo_adodb.php. I think I\'ll stick with the plain mysql driver.
- I need to retrain my brain to match the MVC model, I\'ve gotten used to thinking of my web sites not as a single application - I think that\'s what CakePHP promotes - but as a bunch of pages / urls that call one or more \"applications\" or \"modules\" that are part of the site (blog module, image gallery, etc...).
- Other terms I need to learn: \"objects\" or \"datatypes\" are the \"Models\", \"apps\" or \"modules\"\ are \"controllers\", \"templates\" are \"views\"\
- I\'m not sure if I\'ll like how all controllers go in one folder, all models in another, and views in another. Seems that would make it tedious to try to move all the code related to a blog, for example, from one site to another. Or, I\'m too used to having everything related to the blog in \"apps/blog\".
- Unit testing should be pretty straightforward, see TestingCakeApps, at least one should be able to use SimpleTest to make sure your Model and Controllers don\'t break as you change code.
- Not related but ran across Mollio, a set of CSS and HTML templates that may be a good starting point for having \"switchable\" templates on a site.
I\'ll keep writing up my experiences working with Cake, its a good way for me to record what I learn. To read: impressions of CakePHP from David Machiavello, a \"baker\" to automate creating your Model/Controller and other files, and the cake baker blog.\
Categories: PHP