published on February 8, 2011 in technical
1. Why do we need frameworks?
The answer is simple from some poits of view, but from others it is not. The best way would be to be ale to build up each our site from scratch, ensuring that we make no compromise this way. But nowadays this is not possible, life and time is not going to allow us to do this each time, it would be way too exoensive and bad for everyone..
This way we are bound to use some way to make our work faster.
2. The choises
There are alot of PHP frameworks on the market, most of them free of any fee. For the purposes of this article, I have chosen four of them. Codeigniter, because of its great learning curve, Yii, as a straight opposite of the first, DooPHP, because of its claim to be the fastest Kohana, my favourite. Beyond these, there are still many out there, try the if you wish.
Actually there are no criteria, this is my personal oppinion of the frameworks I write about.
Also, I do not care about the footprint of a framework, or anything similar. Nobody is serving “Hello World!” strings with a PHP framework, this is not what we use frameworks for.
From the four, Codeigniter is the one with the best learning curve. It has a great online documentation here http://codeigniter.com/user_guide/index.html, which is perfectly structured, with lots of examples.
Maybe you have already noticed, there are only MVC frameworks in my article. This is not because of any modern thrend, but because life brought it like this, I did not use any othe kind of framework.
Also very good about CI is its comunity. Way bigger then in the other cases. In case that you cannot find what you need in the documentation, there are going to be thounds of gents to help you online.
There are also negative points on behalf of CI. My biggest problem is its way of handling cache. I never needed page cache, I think if someone needs ony page cache, he probably doesn't need cache at all.
This is the way you cache an output in CI. This is a very simple way of using cache, but it is actually useless. You cannot tell CI what to cache, what data you want to be cahced. Also, there is no way of telling the key name.
This is a big problem for me, because I never needed to use cache like this. I always cached parts of the page, which apear on other pages, or ajax responses, or just parts of these. I annot do this with CI.
Other classes, helpers for example are still very good, but the above problem is a no go point for me, I cannor use CI for any of my projects.
When I encountered Yii, it was just before the final 1.0 version. Let me say, that it has evolved alot since then, along with its documentation, which at that time was actually not existing.
It was just the opposite to CI, very difficult to learn, with a very, very bad learning curve. It had no documentation then, which made thing even worse. Also, the code was changing, buildin quite fast, making learning even more difficult.
For me, a good framework is one which I do not need to know from within. Weel, Yii is not like this. It is created for people who use good IDE-s, like Netbeans IDE, and navigate through code, this way knowing it from the inside out. As a web developer, I do nt really have time to getting to know a framework like this, it is not effective at all. If I did that, I might as well create a framework from scratch.
Due to much better present documentation, and a growing community, the situation hase become much better then two years ago. But I am still leaving out of my plans, because then it was too immature for me and I voted for a different framework, which comes next.
Kohana-s current version is 3.1, and is a child of Codeigniter — back then it was forked from it, when some people were not pleased anymore with the evolution, working of CI, mainly the fact that it was backwards compatible with PHP4.
There is very important hing to state here: Kohana 3. is a bit confusing, because it actually has nothing to do with 2. There are two different teams working on these, totally apart from eachother.
I got to know Kohana at the same time when I met CI and Yii. Kohana was the one which got my attention, due to its good learning curve, a good community behind it, it inherited CI's simplicity. It had a lot of modules, like a real cache, a good and simple ORM and a fairly simple ACL.
Its modular organization is the best thing in the world. It makes my life a lot easier. I just build up modules for the thing I want to achieve, and load the if needed. The modular organization is true on the filesystem too, I took me about a blink to getting used to that.
This site is based upon the Kohana framework, it made things alot easier. It gave me lots of optimizing possibilities, amongst the is the E-Tag checking an setting.
Besides the core framework functionality, there are lots of third-party modules. Minify, AMFPHP, bonafide and manny, many others make the life a Kohana programmer very easy. Also, creating a new module is not complicated al all. It is actually peace of cake.
There are fo course modules that I feel should have never been created, like the Kohana-for-Wordpress. I think Wordpress is aomething that, from a programmer's point of view, is very badly build, it should never be combined with Kohana, of with any other framework for that matter, because this would lower the quality of that framework.
As they mention it on their site, there is a good chance that DooPHP if one of the fastest MVC frameworks around. Of course, this chance is granted to any other framework. From here, it is not very easy to tell. But that statement made me curious enough, to tryit a bit.
Its install and configuration is as easy easy as in the case of CI. In a couple of minutes, we are ready to go. The routing may be set in a configuration file, but we have no named routes. Also, the form of setting the routes is similar to the previous versions of Kohana, which I find a bit outdated.
Something I love about it, is its ORM. Very simple, very basic, but still good and fast enough. I am no big ORM fan, but I have always loved such simple things.
Doo, like all other modern frameworks has a code generation possibility. The name of the class which does this is DooSiteMagic. It can create all your controllers and sitemap based upon the routing. In the case of a new web application, this might even come in handy.
DooPHP loks very interesting, it made me courios. I shall certainly try it on one of my future projects. And, I will probably write a more detailed article about it.
There are a few bigger frameworks hat I left out of this article. Amongst these is Symphony, CakePHP, QeePHP. My oppinion about Symphony is that if youwand to do something wrong, this is how you should do it. Sadly, Yii is moving fastly in the same direction. The other two — well, I shall probably write about them in future article.