Home » PHP » PHP MVC Frameworks » Yii vs Zend vs Code Igniter Comparision

Yii vs Zend vs Code Igniter Comparision

January 6th, 2011 Leave a comment Go to comments

Choosing a PHP framework is not an easy task, especially if you have relatively little experience in PHP to know what makes a good framework or and what doesn’t, but choosing the right PHP framework for the job is absolutely critical in the long term as choosing the wrong PHP framework can lead to a number of negatives, such as longer development time, need for more experienced staff who may be hard to find and of course performance problems.  Unluckily (or perhaps luckily) when it comes to PHP there is such a plethora of PHP MVC Frameworks that it’s damn hard to actually boil them down to the final choice.  With ASP.NET for example it’s quite easy (although it’s gotten a little more complicated lately), previously there was only ASP.NET but now there’s also ASP.NET MVC, which is very different development paradigm and has it’s own catches.  However, one thing with .NET is that you need to choose how you’re going to do your data access, etc, but with most PHP Frameworks there is usually only one or two ways and they tend to do the job quite well.  So, now with this brief introduction, here’s the thoughts on Yii Framework (1.1.5) vs Zend Framework (1.11.0) vs Code Igniter (1.7.2).

Firstly, why did I decide to actually compare Yii Framework vs Zend Framework vs Code Igniter?  Well, the reason is actually pretty simple… These are pretty much the only 3 frameworks I would consider or rather they are my final 3 of like over 10 PHP Frameworks that I’ve looked at.  The reason Symfony isn’t in this list is because is too damn big and slow and unless you’re building some crazy huge enterprise project it’s not something you’d want to use as it’s slow (and why would you use it when you have Zend Framework).  The reason CakePHP isn’t in this list is because it really forces into doing things the way it wants you to do things and the moment you want to get into something a little more out of the ordinary (which often I do to improve performance) it can’t handle it and it’s also quite slow.  The reason the likes of DooPHP, Solar, Akelos, Prado, eZ Components, Seagull, WASP, etc aren’t in this list is because they’re not quite at the scale (in terms of user community) I would want them to be to actually be considered to be in this top 3 list.  Many of them are outdate and aren’t being developed further or are just akward to use and slow or short on features.  The reason Kohana PHP isn’t in this final 3 list is because I just don’t like the way it’s been written… If you’re an experienced OO developer and you crack open Kohana you just get lost… it’s all over the place.  It’s not a true OO PHP framework in that it uses the paths and all kinds of craziness to do overriding instead of just using plain old inheritance.  All this means additional file system operations and just plain ugliness, and the user community isn’t all that strong like it is for the top 3.

Now, in relation to the top 3 frameworks, being Yii Framework (my preference), Zend Framework and Code Igniter.  Firstly I’ll talk about Code Igniter and Zend as to who they’re my second and third preference as opposed to my first preference (being Yii Framework).   In fact I would have to say that Zend Framework and Code Igniter share an equal second for me as they’re just so different that it’s not really possible to say one is better than the other and should be chose over the other.  I also have to say that I have quite a bit of experience with PHP frameworks, having written some, reasearched others (including actually cracking the code open and tracing through the execution using Eclipse PDT and xDebug) and used the top 3.

Firstly, I’ll start with Zend.  Zend Framework is actually quite a nice framework in terms of it’s completeness and the fact that it is properly designed in terms of OO and lets you do things the way you want to do them without forcing you to learn some new language like Yaml.  However, I have a number of issues with Zend Framework.  For one it’s very verbouse… that is, you often have to write a fair bit of code to do something simple.  This is fine for an experienced developer, but still takes time and time is money.  The second issue I have with Zend Framework, and for me this is the real deal breaker, it is damn slow if you don’t have opcode caching, so if you’re looking to use it for something that will be hosted on a shared server and/or doesn’t have opcode caching, just forget it!  The reason for this poor performance is that the classes are split between so many files that you basically end up doing a hell of a lot of file system operations to load all the classes.  The last thing, which seems to be a deal breaker for many people is that it’s damn complex and the learning curve can be quite steep who isn’t familiar with Patterns of Enterprise Application Architecture (I strongly urge you to read Martin Fowler’s book if you want to become a good OO programmer and easily understand the likes of Zend Framework).  There’s probably a few other smaller drawbacks I could list (e.g. using text and xml based configuration instead of harnessing the power of PHP arrays for configuration like Yii), using long class names (which is needed to overcome the lack of namespaces prior to PHP 5.3) and a few other little things, probably not worth mentioning.  So from this perspective, Zend Frameworks kind of comes in as being too big and complex and that’s the reason for not choosing it.

Now for Code Igniter.  There are a few things about Code Igniter that people really love, being the huge community and the simplicity.  It is not doubt quite an easy framework to pick up for a novice, however, it also has a number of drawbacks.  Firstly, the current version of CI being 1.7.3 is still backwards compatible with PHP 4.  This means un-necessary code and all kinds of other crap.  The second thing is that although it’s quite a complete framework it actually lacks many of the things you actually want when you develop serious complex applications (not just some little amateur website). These things include proper support for templates, user controls (or widgets as they’re called in Yii), integration with jQuery (which I dare say is now the defacto standard for client side frameworks, since it’s now supported by Microsoft) and all kinds of other little things.  When you look under the bonnet you also see alot of ugliness… I mean it’s nice simple PHP code with a few unnecessary things in my opinion (e.g. check if the functions exist, using EXT to define the .php extension and appending that onto everything), naming and lack of code completion support in PHP IDEs such as Eclipse PDT and Net Beans and just plain ugliness.  Sure, it’s nice that it’s nice and simple, but it just isn’t quite there.  I would really love if there was a framework as simple as code igniter in it’s structure, but which used more proper OO techniques, the likes of Autoloaders, didn’t do unnecessary stuff like define .php in a separate constant which is appended everywhere and so on.  I’d be more than happy to manually instantiate the objects I required in some init file and do a few more things manually rather than relying on the framework to magically do them for me.  If there was such a framework I would more than happily use it for little projects, but unfortunately there isn’t one.  The closest thing I have found to this is the PHP Pro MVC framework tutorial and the framework used in OpenCart (although I thing it has some shortcomings too).  Unfortunately, Code Igniter is not this framework and falls short of what I would want for a simple framework.

Finally, I come to Yii.  I guess the thing with Yii is that it fits in nicely right between Zend Framework and Code Igniter.  It’s probably not the simplest to learn for a PHP or OO novice, but for an experienced OO developer it’s a breeze.  It has great documentation and if need be you can always inspect the code yourself.  I actually spend quite some time developing in ASP.NET and Yii feels very very similar.  It has used some of the best concepts from ASP.NET and from many other frameworks and because it’s strict PHP5 and strict OO (without crazy hacks that are typical of inexperienced PHP developers) it’s very very easy to learn and understand as long as you understand the basic principles of OOP even if you have little experience in PHP.  The thing with Yii is that it’s more comprehensive than CodeIgniter and better structured, yet smaller and more robust than Zend Framework, requiring a hell of a lot less code to get stuff done, while giving you all the same features and more (e.g. Code generation with Gii).

So, I ultimately think any experienced architect/developer will come to the same conclusion in terms of the best 3 PHP Frameworks but the ultimate choice is really going to depend on your needs and experience.  I guess the important thing with all 3 is that it’s easy to find resources, as these are probably the most widely used php frameworks these days.  In terms of choosing, if you’re doing a large scale enterprise project then I guess you might not have much choice but to go with Zend as it’s has a company behind it, it’s proven and so on, but be prepared to spend a fair bit of competent staff and hosting.  For a hobbyist or someone just starting out with PHP and not much experience with OO programming, CodeIgniter might be the way to go as it’s nice and simple and pretty easy to get your head around.  It’s also nice and light and has a very large user community and availability of resourced to learn from.  If you’re an experienced developer but don’t want to waste time writing lots of code to do simple things and don’t want to pay an arm and a leg for hosting, but want something that’s mature, well designed and nice middle ground between Zend and Code Igniter then you’ll probably choose Yii Framework like I did.

Hope my rant helps people with choosing the right framework for their needs and I’m always open to feedback.  Also, if anyone knows of a lightweight PHP framework, which doesn’t try to be too smart and is pure PHP5 OO then I’d love to know about it.  I don’t believe that such a framework needs to have stuff like ORM, ActiveRecord and all other bells and wistles, just needs to be lean, mean and fuctional.  Perhaps if you’re interested in writing such a framework I’d also be very much interested in hearing from you and perhaps even conributing.

Categories: PHP MVC Frameworks Tags:
  1. czechspekk
    January 6th, 2011 at 14:45 | #1

    “The reason Symphony isn’t in this list is because is too damn big and slow and unless you’re building some crazy huge enterprise project it’s not something you’d want to use as it’s slow (and why would you use it when you have Zend Framework). ”

    You made me laugh :)

    1. Symfony, not Symphony.
    2. It’s not as slow as you may think – depends what version you want to use and what actually you do with it – http://symfony-reloaded.org/fast
    3. It’s not big – it’s full stack framework where almost everything has been thought through.
    4. You don’t need to write enterprise projects to enjoy working with symfony.
    5. You can use any Zend class as library inside Symfony, not vice versa. So why would u use pure Zend and write a lot of code if you can use Symfony, configure what you need, import required Zend libs and be happy to be lazy.

    You should have said it straight that Symfony has steeper learning curve and that’s why you wouldn’t consider it as a competitor :)

    Symfony +1

  2. January 6th, 2011 at 18:29 | #2

    Great review of the major PHP frameworks.

    The nice thing for me about Yii is that it allows us to use ORM (ActiveRecord) for tedious operations like editing and saving content where the cost of running SHOW CREATE TABLE is low, yet we can use precise SQL queries for the fastest performance on frequently viewed pages.

    Previously I also thought that it would be better to not have an ORM, but the productivity benefit of being able to just add a column to the database and have it appear automatically in the edit form is worth it.

  3. January 7th, 2011 at 19:13 | #3

    I have to agree Yii is such a nice frameowrk to use – I was a big fan of CakePHP but it just seems to grind slowly once you get over even a moderately sized app.

  4. January 8th, 2011 at 11:51 | #4

    Ok, big deal, I mis-spelled Symfony… I’ve actually spent a bit of time learning and understanding symfony as well as a fair bit of time looking at performance and I can’t say that Symfony is the wonderful thing you proclaim it to be. Most importantly, what’s the point of linking to Symfony Reloaded which IS NOT A PRODUCTION RELEASE? Unless something is in production and being used by a wide audience I’m not interested in it (and nor should be anyone looking to build serious apps using the framework). Besides, why should any programmer be required to learn a new configuration language to use a framework? If you understand PHP, OO, SQL and web stuff like HTML, CSS, JavaScript, jQuery you shouldn’t need to learn more stuff just to be able to build something. Besides this the problem with Symfony is that it leverages a few bulky components and that certain impacts speed. Any realistic speed test should compare the performance of a framework which has at least some basic DB operations! That’s why I think both Zend and Yii are very good in that regard, they’re pure OO PHP frameworks without inventions that in the end make life difficult. For me the community was also very important and I felt that the top 3 I’ve chosen had much better communities.

  5. January 8th, 2011 at 11:57 | #5

    Yes, ORM is nice from that perspective, but I also think it isn’t necessary in PHP when you can make use of associative arrays like data transfer objects. Anyway, i guess ORM is here to stay and to be honest I don’t mind working with it, but for fast retrieval I think it’s best to write your own SQL and perhaps not use Active Record but stick more with a thin DTO loaded using a data mapper perhaps. Anyways, I think that performance is a bridge that only needs to be crossed when you come to it as long as you know that you may come to it and think about it ahead of time. As for SHOW CREATE TABLE there’s not need to run it all the time if you use database schema caching in Yii. I made a post about it before in the Yii forums I think and the performance difference is huge. I also use FileCache for schema caching if I don’t have memory based caching alternative available as it’s still faster than getting it from the DB. I would also recommend using FileCache on any relatively static pages if you want the best performance (but I’m sure you do this already).

  6. January 8th, 2011 at 11:59 | #6

    Performance is just one problem with CakePHP, perhaps the bigger problem is the fact that is forces you into doing things it’s way and that’s mighty annoying when you try to do anything more out there.

  7. jpj
    January 10th, 2011 at 15:21 | #7

    Just one thing, I think one should not compare Zend with Yii or symfony. Zend is more a big library than a framework.
    I think a good choice is to use a framework that generates some code, and to use parts of Zend for special needs (zend_lucene to implement search engines,…).
    Yii and symfony are interesting because they can generate some code so we can focus on the specific parts of the application. And Yii is lighter and simpler to learn than symfony.
    After having tried Zend for one year, symfony a few months, and Yii for 4 months, for small applications, Yii is my prefered tool, because it’s light, fast, easy to learn, easy to extend.

  8. Magic
    January 10th, 2011 at 15:39 | #8

    ORM is essential for Rapid application web development as it eliminates you having
    to right all the plumbing code, ideally this should be used in the admin section of your
    applicaton, also if used correctly with schema caching and File Caching
    together with APC there should not be a big performance hit.

    for front-end which is visible to all users I would probably convert the ORM code to
    Data Access Object (DAO) code to improve the performance if that is required but
    honestly if your developing for an enterprise the hardware is probably higher end and
    the difference would not be that noticeable compared to a cheap hosting account.

  9. January 11th, 2011 at 00:05 | #9

    There is no reason why you can’t compare Zend with Yii or Symfony. Zend is as much of a framework as the other two and not just a library… i don’t know where people get that impression. The Elements of Reusable Object Oriented Design book by the Gang of Four actually covers the difference between a Framework and a Toolkit Library quite well, being that a framework guides the overall application flow while toolkit library is something you use. Zend framework does both as do other big frameworks like .NET Framework for example. The only thing with Zend is that it’s loosely coupled (as it should be) and Yii for example has very little in a way of toolkit library functions.

  10. January 11th, 2011 at 00:11 | #10

    Yeah, the more I work with ORM the more I find I don’t really have any major issues with it as such. It’s basically the 80/20 rule… 20% of your queries account for 80% of your operations and hence it’s not a problem and for those 20% you can hand-write them. As long as ORM doesn’t destroy performance too much it’s not so bad, but it is a pain in that it’s just another API to learn. What I think is having something like CDbCriteria and CDbCommandBuilder in Yii is actually quite nice. You really do need some sort of an object or array to hold the different parts of a query when you construct it if you have complex dynamically built queries.

  11. jpj
    January 11th, 2011 at 08:03 | #11

    Well, in fact I agree with you, we can compare Zend and Yii. For me Zend is slow, complicated, rather long to learn. There are a lot of classes, sometimes almost empty. For me it lacks models/forms/controllers/views generation code, based on the db structure. So you need to write some code to do common things. I don’t say Zend is bad or useless, my experience is that I’ve wasted more time using Zend or symfony than Yii.

  12. January 11th, 2011 at 08:07 | #12

    czechspekk :
    “The reason Symphony isn’t in this list is because is too damn big and slow and unless you’re building some crazy huge enterprise project it’s not something you’d want to use as it’s slow (and why would you use it when you have Zend Framework). ”
    You made me laugh
    1. Symfony, not Symphony.
    2. It’s not as slow as you may think – depends what version you want to use and what actually you do with it – http://symfony-reloaded.org/fast
    3. It’s not big – it’s full stack framework where almost everything has been thought through.
    4. You don’t need to write enterprise projects to enjoy working with symfony.
    5. You can use any Zend class as library inside Symfony, not vice versa. So why would u use pure Zend and write a lot of code if you can use Symfony, configure what you need, import required Zend libs and be happy to be lazy.
    You should have said it straight that Symfony has steeper learning curve and that’s why you wouldn’t consider it as a competitor
    Symfony +1


  13. jpj
    January 11th, 2011 at 08:59 | #13

    Maybe it’s out of the current post but, the more it goes the more I feel like writing my own “framework”, for some reasons presented here : http://www.sheldmandu.com/php/php-mvc-frameworks/writing-a-fast-php-mvc-framework-part-1.
    I think there’s an interesting debate about writing its own framework.
    Writing its own framework is not reinventing the wheel. Writing its own framework (if you’re a PHP experienced developer of course) could be faster than learning another framework, the framework itself will surely be faster than a big complex one, it’ll focus on the points you need, you won’t lose time wondering how one thing or another works, and it’s enriching because you really improve your PHP skills and you build something on your own. Security problem ? anyway, whatever framework you use, you can always find a way to put flaws in your app if you’re a bad developer. Long job ? Maybe faster than learning another framework. Up to now I use Yii because I’ve never been stuck with it but the self made framework is still an idea.

  14. cr
    January 16th, 2011 at 05:25 | #14


    I just came across your site looking for activerecord vs “other”. Saw the side link for this article and starting reading. What got my attention was that you briefly mentioned the “PHP Pro MVC framework” and “opencart”, which are the reasons why I was searching the net. (note: I have been working with opencart recently)

    I am self learned when it comes to programming but I too think that opencart is lacking on the MVC side. I too came to the conclusion that yii would be a choice to use. But once again, my reasoning is based more on various google searching than on learned ability and knowledge.

    Would you mind taking time to list the items that are missing from the base MVC framework that opencart is based on? Better yet would be explanations as to why, too? (However, I’d be happy to google everything that is on your list if a more detailed explanations are too time consuming,)

    I am thinking at the moment to implement or improve upon in the opencart MVC framework:
    – PDO with the xPDO wrapper (I am still debating about doctrine)
    – twig template system (I was never a smarty fan but … some template designers are looking for an easier to use system)
    – still researching the cache implement
    – still researching how to fill out the framework to include a bit more functionality for users

    However, I also have a feeling that I’m going in the wrong direction which is why I really appreciate you comments and help!


  15. January 17th, 2011 at 00:17 | #15

    This comment probably isn’t exactly related to this post, but I’ll answer it anyway. Basically the problem with the framework used in OpenCart is that it’s missing bits like caching and a few other things that something like Yii has. The MVC implementation itself is more or less fine except that instead of using the output buffering with caching, Daniel has chosen to split the header and the footer into separate files so you end up with unclosed/unopened tags in each file and it’s hard to edit as you need to edit both. He had the right idea in OpenCart 1.3.4 but then decided to change for the worse. I’ve told him about it but he gave some silly reason for doing it that way and I couldn’t be bothered debating it with him. OpenCart doesn’t use PDO or prepared statements either, but that’s not big issue. Also, Daniel is hell bent on not using any static methods inside classes and things it’s better to put everything inside a registry object to pass it all around (e.g. DB object) and so on, so there are certainly lots of improvements to be made. The way he does translation also kinda sucks because he manually moves strings around in the controller and that is a lot of fairly useless code. I really don’t have the time to go through all the little bits, but if you’re developing something from scratch than you’re better of using Yii. If you want a shopping cart to hack up for your own needs then OpenCart isn’t such a bad option i guess as there aren’t many better alternatives that architected at least as well as OpenCart. e.g. PrestaShop sucks big time when you pop the hood and so do most other Open Source carts.

  16. cr
    January 18th, 2011 at 14:14 | #16

    Thank you for your reply, also sorry for taking your blog entry in a different direction.
    Can I contact you more for pursuing this?

  17. January 18th, 2011 at 23:35 | #17

    Sure, I can certainly give some guidance but I won’t do the research you should do yourself.

  18. John
    January 25th, 2011 at 06:35 | #18


    First of all thank you for the article. I have recently finished coding my first application using Codeigniter. I am looking at potentially switching frameworks but I don’t feel as if I have a good grasp on OOP programming and for that reason am afraid to dive into Yii. I know you recommended Martin Fowler’s book but I am looking for a OOP book based around PHP. Could you possibly recommend a book or two which would get me up to speed in preparation to use Yii? Any opinion on if the Yii book is worth purchasing?

  19. January 25th, 2011 at 12:20 | #19

    I would certainly strongly recommend taking the time and getting to understand OOP and Yii as you will be able to implement far more complex projects with greater ease if you learn and apply the concepts. I don’t think that lack of OOP experience will stop you from learning Yii and Yii is a good example of OOP done right (in PHP) so that will be a good learning experience. In terms of books I truely believe that Patterns of Enterprise Application Architecture by Martin Fowler is a MUST have for any self-respecting programmer. It does not focus on any particular language as such (in fact it covers some specifics of different languages). What the book is really about is OO Design Patterns. For example when Yii or some other framework refers to ActiveRecord or MVC or FrontController or PageController or DataMapper or Data Transfer Object they are all using the terminology defined in that book… It’s like the bible of high-level high-quality software design. Once you read and understand that book you will actually be able to make decisions on what’s good and what’s bad in what circumstances and reason as to why that is the case. This is important when analysing and choosing frameworks. You should also read Patterns of Reusable Object Oriented Design book by Gang of Four… That is kind of the low-level software design bible. It explores such patterns as Singleton, Factory, FactoryMethod, Strategy, Facade and so on… These are all lower level design patterns, while the patterns in Martin Fowler’s book are high level design patterns (and may themselves use the low level patterns). In terms of PHP I would certainly recommend PHP 5 Objects, Patterns and Practice book by APress. It is a good book that covers much the same patterns but with more specific focus on implementing them in PHP. Hope this helps.

  20. John
    January 26th, 2011 at 17:48 | #20

    Great! Thanks a bunch for your comments I am going to buy a few books and get into Yii soon..

Comment pages
1 2 3 5 108
  1. January 7th, 2011 at 02:52 | #1
  2. June 20th, 2011 at 08:21 | #2
  3. June 26th, 2011 at 16:08 | #3
  4. July 21st, 2011 at 10:37 | #4
  5. November 17th, 2011 at 06:24 | #5
  6. September 3rd, 2012 at 00:27 | #6
  7. February 23rd, 2013 at 02:29 | #7

3 + nine =