Getting back into cakePHP

I have just started an internal project at work to create a portfolio management system. After several months of Joomla hacking it seems this is my chance to get back into serious development again.

I have gone for cakePHP for the project, as opposed to Codeigniter. Although I have mainly tended towards codeigniter in the past for applications, It has been a while since i have really used cake i was drawn in by cakePHP’s features.

One feature i am finding particularly useful is the elements (using renderElement), as a lot of the forms use similar listings. Instead of using requestAction, I load the data into a standard variable (e.g: $campaigns, for campaigns) from either data already loaded or direct from a custom function in the model. This removes the need to call a particular view from within the element and reduces the bloating of the controller as suggested by the article Skinny Controller, Fat Model.

Jamis says:

Be aggressive! Try to keep your controller actions and views as slim as
possible. A one-line action is a thing of wonder, as is a template that
is mostly HTML. It is also much more maintainable than a view that is full of assignment statements and chained method calls.

I have found that this approach has indeed made my life a lot easier, It’s soo easy to get tangled up in controllers, and sometimes reapeating code when there is simply no need.

I haven’t tried to understand the paging yet, but based on a couple blogs I’ve read, it works the same as the find command, although I’m not sure how paging would work with several tables on the page – I guess I’ll find out in the next few days.

Tags: , , , , , , ,

You can leave a response, or trackback from your own site.

Leave a Reply