There are a huge number of PHP frameworks available on the Internet. Some have a tremendous amount of functionality and take up a lot of space and others are slimmed down to speed up response times, called microframeworks. Zend Framework 2 weighs in at about 250Mb, that's a lot, Laravel weighs in at about 8MB, and Kohana 3 at about 2Mb to give you an idea. The reason there are so many is that after you've been developing for a while, everyone thinks they can build a better mousetrap.
Let's take a step back, and ask why you'd want to use a PHP framework. Well, the answer is, frameworks can provide a bunch of plug and play functionality, built-in, that you can use in your projects. Functionality that you need in every project that you would have to build on your own, if the framework wasn't there. They can provide authentication, security, validation, query builders, testing, and database access, for example.
The trouble is each framework has its own syntax, a different layout, and its own API of method calls, that you have to learn to use. This can take a considerable amount of time. To make learning easier developers like documentation, books, and code examples. And it turns out this is how you separate one framework from another and decide which framework to use. That, and how fast the framework is, how much will it slow down your application, if you use the framework.
One of the problems you encounter in becoming a proficient web developer is separating the wheat from the chafe, in picking which tools you want to use, there are so many, which framework do you want to learn to become proficient in using? Frameworks can save you a lot of time in developing web applications, once you learn how to use them.
So what do I want in my framework. I want a fast framework, why develop an entire project around a slow framework, when there's a faster framework available. I want a framework that has good documentation and examples, and that is easy to learn. It's a pain to learn complicated frameworks without documentation. I want to be able to encapsulate and add my own code to the framework easily. I want a framework that has built in URL routing and and an ORM for database access. I want a framework that autoloads my classes, that is up to date with technology, and I want a framework that is easy to configure and deploy.
Out of all the frameworks out there, there must be one that meets my criteria. Well, one can be the fastest, but may not have the other functionality I want. I thought Zend Framework 2 would be the answer to my dreams, but I'm sad, really sad, to report that it falls far short.
A couple of posts ago, on September 6th, I talked about the new Zend Framework 2 being released, two years in the making. ZF2 had lofty goals: good documentation, being fully PHP 5.3 compliant with namespaces and closures, easy to learn, good documentation, and to be a fast framework. In short, everything anybody would want in a framework.
Now, here it is almost two months later, and its time to take a look to see if those goals has been met. I've scanned the reviews, cloned the framework to take a look under the hood, and looked at the benchmarks. The results are not good.
First, the performance benchmarks. I am indebted to the Ruilog blog for a very thorough benchmarking of PHP frameworks.
The graphs show that ZF2 is about four times slower than ZF1. Zend says this will be improved in later releases, but how many months, can I wait, and do I believe that it will end up a fast framework? I think not. To top that all the reviews say that, because of dependency injection, ZF2 is hard to learn and understand, and because it's new, the documentation is not quite there yet though, it too, is coming.
What the benchmarks did do for me, however, is it caused me to take a look at other frameworks, and in doing so I discovered a framework that does meet all my criteria, finally.
Let's digress, second, here's my list of frameworks that should be on your short list of frameworks to consider: Yii, Fuel, CodeIgniter, Kohana3, ZF2, Symfony2, and Laravel, that's about it. Apologies to all the others.
Let's do a quick summary.
Performance wise, CodeIgniter, Yii, Kohana3 are all about the same in performance, which is a step above all the other frameworks, except Laravel.
ZF2 is the latest. The reason you should consider Zend Framework 2 is it was created by the company that makes PHP, and ZF1 was so popular. Other than that the framework has not lived up to its hype.
Yii has a learning curve, but has good documentation. It features command line code generation of various sections of your application. It has a large user base. This is a popular framework.
CodeIgniter is known for its good documentation, and finally supports PHP5, without PHP4. It has had problems in the past taking a long time between updates and bug fixes.
Kohana3 is a fork from CodeIgniter that went their own way. The problem with Kohana had been their lack of good documentation. It's much better, as version 3 matures. It has a HMVC architecture and a cascading file system.
Fuel takes the best of other frameworks, uses the HMVC architecture, a cascading file system, and has good documentation, but its a step slower.
Symfony2 is made from a bunch of reusable components, it's performs about the same as Fuel. Symfony components also are used in other web applications. This is a popular framework.
And finally, we have Laravel. Laravel is the fastest full stack framework of this bunch, it has the best documentation I've seen in any framework, better than CodeIgniter's. It's has a consistent syntax across the framework, and a built-in ORM. I recommend you take a closer look at this one. I will review Laravel in my next post.