My Experience with PHP Frameworks – Yii, CodeIgniter, and Symfony

Overview

A week ago I started work on a personal web project using PHP as my programming language of choice. This wasn’t a hard decision as I use PHP daily for work and have a great deal of strength in the language.

As I set forward to create my web app I knew I wanted to use a prebuilt PHP web framework. My reasons included not wanting to reinvent the wheel and the belief that the benefit of open source software is its great community of support.

Another reason I wanted to use an open source PHP framework was that it provides a tried and true framework complete with features that I otherwise would not have time to code myself. Although this project is being done during my free time I don’t want its quality to suffer. So by using a framework that already provides proper request/response, and routing support it would allow me to focus on designing and developing the app and not worry about the architecture that it would be built on.

From my research (lots of Google searches and crawling through and around websites) I found the current top PHP frameworks are:

1. Yii
2. CodeIgniter
3. Symfony

Here’s my interactions with them.

Symfony

I first chose Symfony as the framework to use for my web project. I tried its Quick Tour and found myself agreeing with the design decisions of the software. It made sense to me how things were built and how they were used.

In addition to the content of the Quick Tour I also found the design of Symfony’s website to be quite appealing. Although it is said to not judge a book by its cover we humans tend to notice things that are pretty. The same is true of Symfony’s website. Its pleasing to look at, pleasing to use, and I felt a sense of professionalism and polish that made me feel safe to learn more about the code.

I spent a few nights reading in bed on my iPad the rest of Symfony’s tutorials and docs and finally felt confident enough to begin coding. I did begin doing some coding in Symfony and aside from the difficulty of learning a new project’s jargon I was actually having an enjoyable time using Symfony. That is until I ran into Symfony’s Bundle system.

Symfony’s bundle system is unique. I honestly don’t fully understand it but I was not enjoying learning what I was reading. From what I read it sounds like a very strong design approach to maintainable and self-contained code however it is not a convention I’m used to, nor one that I found myself wanting to learn.

Even more than not understanding fundamentally what a bundle is and what it is used for, from what I understood I felt as if it was overkill for my purposes and would end up slowing my development down rather than help speed it up. As a result I stopped learning Symfony and began looking at the other two popular PHP frameworks.

CodeIgniter

I never tried programming with CI but from what I read I actually liked what the software provided. My biggest irk about the project was its close tie to the commercial ExpressionEngine. Although probably not based on any pieces of truth I could not shake the feeling that by using CI I was using a hand-me-down relative of ExpressionEngine.

Now this is perhaps in no way based on reality but it was my subjective feeling that I got when reviewing the websites. It was that feeling that pushed me away from trying to use CodeIgniter for my project.

I only write this so that the creators of CodeIgniter know that these sentiments and perceptions exist (perhaps only within me). However if its more widespread it should be addressed so as to not lose potential users of the framework.

Yii

I was very apprehensive about using Yii. It’s mostly known as the ‘new-kid’ on the block in terms of PHP frameworks. It’s a framework that doesn’t seem to have as much real world experience as other PHP frameworks as there doesn’t seem to be a wealth of sites using it in their production environment. Nevertheless this was the last choice I had in the realm of PHP and I wanted to see what it had to offer.

Yii is a very solid PHP framework. There is a pretty thorough guide to Yii that I went through and tried out. It’s a very solid introduction to the framework that showcases its code design decisions and teaches you how to use the framework along the way. I liked it and started programming my web app with Yii.

Things were going mostly well. I hit a few speed bumps here and there that a Google search was fortunately able to solve (on Yii’s own message board no less – thumbs up for that). I noticed a large amount of foreign writers (mostly Russian) frequenting the forum which led me to believe that Yii’s popularity lies mostly outside of the USA’s borders. This left me slightly uneasy as I only speak English and I didn’t want to translate to find the answers to my questions.

Nevertheless I plugged forward and continued to code. Yii’s guide was lacking in some aspects however Yii’s api reference is absolutely amazing. If more open source projects had documentation like Yii’s the open source community would be a safer and happier place. The main problem with the API reference is not with the reference but – in my opinion – with Yii itself.

Yii provides a lot, and as a result it has a large codebase. This led to frequent bouts of 8+ Chrome tabs open as I tried to triage the proper function to use for the effect that I wanted. This happened a few times: once with relational support and once with helper function support. After going through these maze-like quests to find what I wanted to do I realized that I had hit the wall. Yii was no longer helping me. It was getting in the way and I did not want that to happen.

That was one of my most important rules: the framework is there to help me get my job done – not hinder me. Of course there are points of friction when learning new software yet when I found myself continuously running into them I did not feel as if I was using the right software for the job.

Conclusion

One of the largest problems I continuously saw when looking for a suitable PHP framework to use was the discord in the PHP community. There aren’t any dominant PHP frameworks (Zend aside which I will forever gloss over due to complete lack of interest).

As a result of there not being one ‘true’ PHP framework that everyone agrees is the best one to use most development efforts are divided among the available PHP frameworks. Were these development efforts united under one project not only would the amount of developers supporting the software increase but it would also help decrease decision fatigue.

When I was searching for what PHP framework to use I found myself growing quickly tired trying to decide which one was the best and which one would help me the most. After a while I had to put blinders on and just start trying to use each PHP framework that I wanted but the process to get there was much longer than it should have been.

Perhaps I’m unique in this situation but I doubt it. If there were only two frameworks to choose from, or frameworks that were obviously created for entirely different purposes that would have made my decision making process umpteenth times easier.

Yet at the end of the day I found myself striking out. Whether for subjective or real reasons I did not enjoy my experiences with any of these PHP frameworks. Also my pinky finger got really tired holding shift so that I could write $ all the fricken time. It’s the small things that matter and all those $ add up.

I’ve now decided to try my hand at Ruby On Rails. It’ll do me good to try my hand at another language. I’ve already ported over what code I had so far from Yii in about half the time it took me to originally create. I’m liking it so far and will of course update again with future reflections.

Update: Check out my thoughts and reflections of my time spent developing with Ruby on Rails

  • cpa

    Yii’s got a steep learning curve, and my early experiences with it were similar to yours. But I found that once I knew it, it really helped me fly. Anyway, good luck with RoR!

    • http://harrywolff.com/ Harry Wolff

      I can definitely see what you mean.  Once you become fairly familiar with Yii’s built-in methods and way of doing things I’m pretty sure it makes creating a web app very easy.  Thank you for the well wishes!

      • aussiechris

        Harry, What do you believe is a good way to reach this milestone that you mentioned?

        “Once you become fairly familiar with Yii’s built-in methods and way of doing things”Thanks

        • http://harrywolff.com/ Harry Wolff

          I wish I had a good answer to this specific question but unfortunately I do not.

          The best way to get good with any framework though is through using the framework. One day things will start to click and you’ll understand how to use the idioms of the framework to their fullest advantage.

          • Malek Sufiyan

            am going through same situation.. so, which one i have to choose..???
            waiting for reply…

    • Romain

      Trying Yii right now on a small project. Seems like a nice framework.

  • NAYZAKAY44

    do you think yii more powerful than symfony2 ?

    • http://harrywolff.com/ Harry Wolff

      I found both Yii and Symfony2 to be equally powerful.  By that I mean you can do pretty much whatever you like with both frameworks.  The major difference is how you do what you want.  Personally I found Yii easier to understand as Symfony2 has the ‘bundle’ concept that I found confusing.  And, of course, YMMV.

  • Pingback: PHP Web Framework 搜查 « 在電梯裡遇見雙胞胎

  • http://twitter.com/kayue 家儒

    I have used 

  • http://twitter.com/kayue 家儒

    I have used Yii and Symfony 2 in my projects, I would 100% go for Symfony 2 as I think it is the **correct** way to build site. 

    If you found Symfony 2 hard to understand, or you think you don’t need a full-stack framework, I would suggest you to look at Silex http://silex.sensiolabs.org/ 

    • aussiechris

      @kayue I believe to get your stage of understanding, one must reach the hurdles in coding first. Otherwise it’s hard to understand how Symfony 2 helps. As for me, Symfony 2 will cause lots of headaches as I have 1,000 files to refactor/rebuild in my app, also the fact I would have to learn it, or hire someone to do it and oversee the project. This is where Time and perhaps money comes in as a great factor to the decision. ; )

  • Ninja Turtle

    It’s CodeIgniter dude! I had to make the same decision as you and went with FuelPHP

  • aussiechris

    Hey Harry, I’d love an update on this. March 2012 – where are you at with frameworks. I’m imagining you are still on Ruby on Rails, would like to know what framework, how it helps you, why not changed, etc. 

    Great post, Thanks.

    • Jerry Leventer

      Ditto on the update request… it’s April 23, 2012 – Have you looked a t FuelPHP? Are you now just going to stick with Ruby on Rails?

      • http://harrywolff.com/ Harry Wolff

        Hey guys thank you for your interest!  I started writing a follow-up post about my experience with Ruby on Rails but haven’t finished it yet.  

        Your prodding was just what I needed to wrap that post up and post it.  Thank you for the encouragement.  

        Expect the post within the week.  

        • http://harrywolff.com/ Harry Wolff

          Seems like the blog post will take a little while longer.  Stay tuned.

  • Pingback: My Experience with Ruby On Rails as a PHP Developer | Harry Wolff

  • omederos

    You should really try Django. That’s the easiest framework I have ever seen, and a very powerful one.

    I have tried Symfony2, ASP.NET MVC3 and RoR too.

    If you are used to test your code, Django will make your life pretty easier when writing unit tests for your views (templates in Django), controllers (views in Django) and for your database. You won’t need mocks, stubs, etc. at all

    I suggest you taking a quick look at it ;)

    • http://harrywolff.com/ Harry Wolff

      I’ve tried Django a year or so ago.  At the time I was a pretty big Python novice and as such found Django’s urlconf pattern to be kinda weird – but now I find it to be quite flexible and enjoyable.  Especially when using classes that have their __call__ method set.

      One thing I’ve never never seen anyone best is Django’s admin interface.  That admin page is a thing of pure joy to work with. 

  • Guest

    Excuse me, but isn’t it CodeIgniter, and not CodeIgnitor ? …

    • http://harrywolff.com/ Harry Wolff

      You are absolutely correct.  Wow hah, thank you.  Updated. 

  • http://aalaap.com Aalaap Ghag

    I’ve felt almost exactly the same way and that’s the reason I don’t always use a framework, but when I do, I really do prefer CodeIgniter, because it gets in your way the least. Even I’m learning RoR right now! :-)

    • test

      hi

      • test jr

        well, hello hi!

  • Bethel Goka

    hi Harry thanks for the review i’m going to try FuelPHP i like the calibre of the guys who built it. Two of them where behind CodeIngniter, link:
    http://blog.utahcon.com/computers/code/frameworks/fuelphp/fuelphp-my-new-favorite-framework
    what are ur thoughts

    • http://harrywolff.com/ Harry Wolff

      I’ve briefly looked at the homepage of FuelPHP and at some of their tutorials.

      From my quick glances it seems like a very solid beginning to a framework.

      My only concern with a new framework is the limited community support available. However when getting in at the ground floor you can help build up that community. :)

      Good luck!

  • http://www.facebook.com/HBKsagar Krupa Sagar

    Great Article!!!

    Krupa Sagar.
    http://www.kalonkarnataka.com

  • Victor

    Nice to know that are others in the same situation. Thanks for sharing your thoughts!

  • RomanTsjupa

    Yii biggest problem is its focus on code generation, most blogs/tutorials etc teach you how to use the Gii code generator and stop there telling you next to nothing about what to actually do with frontend and how to customize those generated classes. Codeigniter is solid indeed though, but it’s very slowly updated in terms of new features, that’s actually why it was forked into Kohana some time before. Btw you could try the new http://phpixie.com framework, also a somewhat CI clone, but faster =)

  • Michael Calkins
  • http://www.facebook.com/doonfrs Feras Abd Alrahman

    for business solutions, I left Codeigniter and started with YII.

    codeigniter is too simple , there is no components to reuse , no modules , no client side support ( ajax , widgets)

  • http://www.facebook.com/jim.o.james.1 Jim James

    I’ve been using CI for a medium project, and i have used Yii before too.

    Yii Kick CodeIgniter’s ass.. why? because is so much powerfull, you have to read it and understand it first, has a lot of functionalities

    In CodeIgniter i have to write or download the libraries,helpers, etc for basic thing.. jeezz

  • lucian303

    Well, I sure hope no one hires you to make any sort of architecture decisions. Could you have more arbitrary reasons for dismissing technologies?