PHP is a wonderful language when it comes to variety. You can develop a whole system or a website easily without the need of a framework. However, when you need to deliver real world product quickly and consistently, frameworks are your friends.
Patterns like MVC (Model View Controller) or ORM (Object Relational Mapping) are easier to implement with the use of a framework. One framework that completely changed my way of programming was Ruby on Rails (RoR).
RoR is superb and it has everything I need bundled in it. It’s open source and its conventions such as DRY (Don’t Repeat Yyourself) or Convention over Configuration completely sucked me in. For a number of reasons, I had to move on from RoR but I was not ready to give away all that cool stuff I discovered through RoR.
I first tried CakePHP but I found it be a complete nightmare, the learning curve was too long and I our clients couldn’t afford such a delay. I then switched to CodeIgniter.
The CodeIgniter framework is very good. Its tutorial gets you going in less than 20 minutes. In general, it is very easy to learn and use. It has a great community always willing to help at IRC or forums and there are a lot of good examples widespread over the Web and great plug-ins, too, that simplify your life a lot. Version 2.0 promises a lot of cool things as well. I really enjoyed working at CodeIgniter but I missed the ORM access and having to manually load my libraries/models made me repeat a lot of code. Also, the fact that it’s not fully object-oriented was disappointing for me. I needed something more and that’s when I found Kohana, at the CodeIgniter forum.
I must admit that at first I thought Kohana was the work of some sort of renegade programmers reinventing the wheel. Instead of helping CodeIgniter, their base framework, they decided to make a completely new fork supporting 1) the great additions to PHP 5.x and 2) with a bundled ORM engine. It seems that the reluctance of the CodeIgniter developers to move away from PHP 4 support forced them to do so.
Kohana has all the advantages from the CodeIgniter framework plus ORM and a fully object-oriented programming model based on PHP 5.x+ (e.g., auto loading of classes). On the other hand, Kohana’s documentation is a mess and with very few examples on how to use it. Sometimes I find myself stuck at some point because the examples online are outdated.
There are two branches supported by Kohana, versions 2.x and 3.x, which makes it more confusing. However, once you get past the documentation you’ll find yourself comfortable with Kohana (BTW, to get around the lack of documentation, directly look at the code which is well documented). I found it to have a longer learning curve than CodeIgniter but it is really worth it. Whenever I had any questions, I found the IRC channel very helpful, there’s always nice folks there eager to help you. This was my preferred framework for a long time so I can recommend it fully. Take the challenge, learn Kohana and you won’t regret it.
I found the Zend framework accidentally. I needed to do some work with the YouTube API and the only library I found that would work was inside the Zend framework core. The fact that Zend, the company behind the open source project) was charging money for some of its products kept me away for a while. Then, the team I joined at Nearsoft required some knowledge of Zend. I was reluctance to use it during my freelancer days due to my misconception that Zend was not really Open. I was indeed happy when I found out that it is, indeed, Open Source and has a great community supporting it.
Zend is specially useful when you want to develop a complex system, because of its numerous libraries. There seems to be one for everything you can imagine. But that complexity makes it not so friendly when you only need a simple web page or a small system. Everything is bootstrapped which means the important variables or environment settings are loaded at a single file when the application initialize for the first time. You can have a bootstrap for every layer of your application but that makes things a bit more complicated for simple tasks.
Zend has a great support for unit testing.
This may be obvious but I’ll say it: Zend is fully object-oriented and It’s always up to date with the additions in PHP language such as Namespaces, method overloading, etc.
The Long and Short of It
Use CodeIgniter for learning how MVC frameworks work. Then when you feel you need more (and, trust me, you will), try Kohana, its similarities with CodeIgniter will help you to get on the right track very quickly. Then if you need to develop something more complex (e.g., a system with lots of modules interacting with each other, or you need to access APIs services to YouTube or Facebook), go for the Zend framework.
Unit testing is not a factor as I could easily do unit testing with all the frameworks. If the speed at the server is a factor CodeIgniter performs really well, Kohana follows it closely and Zend is the straggler. Also, uploading your application to an ISP is really easy with both Kohana and CodeIgniter; Zend is not that complicated but it needs further understanding.
I hope you’ve found this a useful introduction to these frameworks. I will dive deeper into each in future posting.
BTW, I’ve also tried Symfony and Yii but the learning curve again was very painful and I’ve not had the time to put into them.
For further information you can visit the following links:
Or you can visit the following IRC channels at freenode.net: