In: Development | 5 Comments
Tags: cakephp, codeigniter, frameworks, php, php frameworks, roundup, yii
By: Ross
Date: 01 June 2010 08:00 am

With the popularity of PHP frameworks increasing steadily each day, I thought that I could give my own two cents regarding which ones I prefer to use, and which scenarios I find each one to be ideal for.
CodeIgniter was the first framework I learned, and thus I continually found myself comparing all the others to it after I began my search for something more complex. Despite the fact that it has had little activity on its Website as well as on the development front, I continue to use it for projects that are highly customised and require more alternative functionalities. I love that it comes with pre-packaged libraries, as I don’t have to worry about integrating something like the Zend Framework to obtain additional functionality, and so far, the CodeIgniter libraries have been perfectly self-sufficient in all the projects I have used it in. If the framework continues to show little activity in the future however, I may move over to Kohana, as it shouldn’t be too much of a change considering it was built on top of CodeIgniter, and unlike CodeIgniter, it has full PHP 5 support and is frequently updated and improved.
Note that CodeIgniter has a basic Active Record, if it can even be called one, and thus, all database queries are specified by the developer albeit using the built-in CodeIgniter database functions which will escape and organise your query syntax for you. Also, form creation is a bit more time consuming as each input and label has to be specified by the developer, and the managing of submitted form data has to be done by the developer as well.
Ultimately, CodeIgniter is ideal for the developer who wants the most control, and doesn’t like to be forced into developing a certain way. It is also very easy to pick up with its great documentation, and thereforce, is a great framework to being one’s foray into the MVC methodology. However, it is the slowest framework I have used when trying to get more complex database-centric site up and running.
CakePHP was the first framework that caught my eye due to its popularity and “magical” code conventions. I found it a bit intimidating for a beginning PHP developer however, so I moved to CodeIgniter until I was more experienced. The “magic” in CakePHP relates to how, if the CakePHP standards are abided by, a lot of the every day functionality that you would have to code yourself is automatically handled by the framework. This can range from the automatic updating of has-and-belongs-to-many tables after saving a record, to dynamic scaffolding and code generation, which will create pages for all your database tables depending on the table schemas themselves, which can be really handy in getting a project started.
I only started using CakePHP after I had become experienced with CodeIgniter, due to the more complex workings of CakePHP, and getting to grips with the conventions it so strictly requires you to abide by. This is both its strength, and weakness. Due to the strictness of the conventions, I often found myself spending hours on just trying to convince the system to do what I wanted, as my functionality requirements weren’t commonplace. However, the more I understood the underlying workings of the system, the less of a burden this became.
Ultimately, CakePHP is for you if you want to spend the least amount of time possible on creating the mundane code required for everyday functionality, as well as if you don’t mind getting your hands dirty by either altering the underlying libraries to add your own functionality, or to create your own plugins, components, and helpers. The only other negative to using CakePHP is its performance, as it is one of the worst performing PHP frameworks out there, but its good caching support helps reduce the problem somewhat.
The framework is currently undergoing a move to version 2, and as such will be shedding its support for old technologies such as PHP 4, and improving the workings of its existing libraries by adding techniques such as lazy-loading. Hopefully, all of these changes will have enough of an increase in performance to make it a worthy opponent for some of the other lighter PHP 5 frameworks out there.
Yii is a bit of a flirt, when it comes to frameworks. It is an excellent performer benchmark-wise, and it has a lot of similarities to CakePHP in its automatic generation of code and behind-the-scenes magic, but it also still supplies the developer with the ability to tweak anything and everything if they should need to. Despite this, I still do not feel confident using the framework. The impressions I get after using the CRUD code generation are good, but as soon as I start making use of the Active Record, as well as the built in extensions, I start to feel like it isn’t made for large scale development. There are many little flaws, that when pushed together, give the framework an undesirable after taste.
One such complaint relates to the classes used in the extensions, which often look like “yw0″ and so on. The URLs used in the pagination of the framework are not appealing, and the extensions along with their documentation are very confusing. I also do not like that the framework doesn’t output descriptive errors if incorrect arguments are supplied for functions and so on. I found myself spending ages trying to figure out why my queries weren’t working, or why relationships between tables were being ignored, and it was because of silly little things, like that a limit could not be applied to complex joins, or that parameters in conditions have to be pre-specified in the model relationships if you wish to use them.
I feel like Yii could be an awesome framework, but I think that it needs some time, and refinement structure wise. I hope that the Yii developers press on and continue improving it, as I believe that in another year, with some better documentation, and more real-world friendly conventions, it could be a great contender to the others I’ve mentioned.
So reading this, you can probably gauge that I prefer CodeIgniter and CakePHP. At the moment I am leaning towards CakePHP for the majority of my projects due to the time it saves me, and how I can reuse CodeIgniter’s libraries in the framework with relative ease whenever I need to perform file uploads, image manipulation, etc. CodeIgniter is definitely the best choice for a beginner or less experienced PHP developer, however. I have briefly looked at other frameworks such as Django and Ruby on Rails, but I have no real work experience with them, so I cannot comment on my feelings as of yet. However, I’m hopeful that sometime in the near future I will be able to. I’m also eager to learn MVC ASP.NET, so if anyone wishes to hear my comments on any of the other frameworks, feel free to request them in the comments, and I will see if I can make it a priority to learn and use the ones you’ve mentioned.
I hope this helped any MVC newbies in making their choice regarding which framework to start using.
Follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
5 Comments
By: Bjørn Børresen
June 2, 2010 at 9:35 AM
Interesting and honest writeup, thanks! I’ve tried all these frameworks at one point or another but have decided to stick with CI for now, almost exlusively because ExpressionEngine is built on CI and it’s used for module development on that platform. No doubt there are php frameworks out there that will do more for you. I’d be interested in hearing your thoughts on Symfony also, for example.
I am however glad to hear that all these frameworks are ditching support for PHP4 now.
By: Ross
June 2, 2010 at 9:47 AM
Thanks for your comment!
I had a look at Symfony, but was intimidated by the fact that you have to change system configuration files to get it running, which isn’t the case with any of the other frameworks. Symfony 2 seems to be getting rid of that though, so as soon as its better documented and supported, Ill be looking at it for sure.
The performance issues in Symfony are also a bummer, as its slower than CakePHP.
By: Per
August 8, 2011 at 6:28 PM
Hi Ross!
We’re a bunch of Swedes who just launched a framework that has been in “stealth mode” for the last few years:
http://meltframework.org
Would love to get your opinion on it!
Cheers,
Per
By: PHP Scripts
October 30, 2011 at 2:31 AM
PHP Scripts…
[...]PHP Framework Roundup[...]…
By: Milton Mair
November 15, 2011 at 4:17 PM
You acquired a really useful blog site I have been here reading for about an hour. I’m a newbie and your achievement is very a lot an inspiration for me.
Post A New Comment