CodeIgniter: I Don’t Hate It

The unfortunate tragedy of my life is that I don’t get to develop in Ruby on Rails all the time. No, unfortunately for me, a large number of my clients need work done in PHP.

Which, as already indicated in several previous nuanced discussions, I hate.

I mean, really really HATE.

But that’s not the point of this post.

After being seriously burnt by the twin miseries of CakePHP’s poor documentation and desperately misguided attempt to mimic Rails I went looking for a new PHP MVC framework for a recent project.

Crucial requirements:

  • lack of opinion
  • simplicity
  • good documentation
  • understands PHP is not Ruby

I really wanted something that was pure VC, leaving out the M.

Views, Controllers and Models can go to hell.

PHP’s complete lack of dynamicism (and yes, I know PHP 5 has a crack at it, but whatever) means any attempt at Hibernate or Rails-style ORM is doomed to failure. And after screaming at CakePHP every time a finder returns an array of nested hashes of arrays of hashes and you can never work out how to just iterate through the records I’ve gone back to ADODB. You run a query and are returned a Record Set. I know this just reveals how long I spent in the late 90s hacking ASP, but if any language was still living in the late 90s, it’s PHP. And it’s actually quite good at it.

Where was I?

Right. Clean View/Controller mechanism. No Models.

Enter CodeIgniter.

It’s incredibly simple, the only assumption it makes is that you may never need most of the stuff it includes, so everything is an option, and it has great documentation.

CodeIgniter: I Don’t Hate It.

If you really have to use PHP, it’s worth a look.

12 Responses to “CodeIgniter: I Don’t Hate It”

  1. Robert says:

    I recently wrote something similar on my blog about CodeIgnitor. I don’t however try to pretend that I’m working in one language when I’m not. And if you think Hibernate or Rails-style ORM rocks, well I envy the simple applications you get to build.

    I do agree with your assertions regarding CodeIgnitor though. nice and simple, pretty darn good docs to go with it and quick to build and app.

  2. Jay says:

    I just started using CodeIgniter recently after a long stint with .NET and (of course) years of classic ASP. I sure wish I could be coding all day long in RoR, but for now, CodeIgniter works just fine. I’m not really happy about their implementation of ActiveRecord, but overall the framework is fast, clean, and fun to work with.

  3. Adam Risser says:

    Hear Hear! I wouldn’t have minded CakePHP so much if the documentation wasn’t so….nonexistent? CodeIgniter has its own issues, but they are usually easy to work around because CodeIgniter seems to not force a lot of convention down your throat.

  4. ktolis says:

    How about Symfony?

  5. Toby Hede says:

    Robert: Exactly right … CakePHP tries to pretend it’s Rails but PHP isn’t Ruby.
    You can however, make very complex applications using Hibernate and ActiveRecord … Hiberntate is the “industry standard” in the Java world and used on *massive* projects.

    CodeIgniter’s biggest benefit is its determination to stay out of your way …

  6. Fijiaaron says:

    I think CodeIgniter’s the best of the PHP frameworks I’ve tried too. With maybe Symfony second. I like CodeIgniter’s simplicity and documentation. Though I tend to want something heavier weight — I really like pushing entities into the model, but the ability to take it or leave it is what I like.

    It’s “not opinionated” as you said, and that’s what I think wins me over, even though, e.g., Cake has more of what I want, I don’t want it served with Cake.

  7. I feel your pain.

    I deal with this by not taking any PHP work from potential clients!

    But I’m sure I turn away a very large amount of work by being that persnickity. :)

  8. Toby Hede says:

    I have to start doing that. I’ve spent the afternoon working on a VB application.

    But VB == still better than PHP.

  9. Fred Wu says:

    PHP has its problems, so does Ruby. They are just tools. It’s like some people prefer Windows, some prefer OS X and others prefer Linux. By the end of the day, it is what offers *you* the most productive outcome that matters. Trashing PHP is not here nor there. :/

    Just my 2 cents.

    P.S. I love CodeIgniter, been using it since version 1.3. :)

  10. Manny says:

    I totally agree with your assertions about Cake’s documentation - it is basically non-existent. Check the forums and you’ll see there are a lot RTFM - like WTF - what manual!

    - Cake has never had a stable release.
    - Current release 1.2 beta has a lot of sheeit deprecated - sign of poor design
    - F’N SLOW. A fairly simple page with a couple of queries takes between .5 to 1 second. This time includes using APC, caching queries and elements (view)
    - uses a lot of memory. From my experience between 6-9 MB per request
    - my pet peeve is you end up writing more code to prep a query than actually writing one. Plus the queries generated aren’t always optimized.
    - very small list of 3rd party/community created components/libraries. This is probably due to the fact that Cake doesn’t follow the Open Source development model - more closed
    - Cake’s slogan of convention over configuration is somewhat BS. In reality, you end up hard coding config stuff in controller and model

    This is just stuff off the top of my head. Cake does make simple apps easy. This is where you get hooked until you have to do something more real world.

    I did work with CI early on but dropped it because it’s closed development was IMHO worst than Cake’s. I would love to see Kohana grow and succeed! Unfortunately, it doesn’t seem to have a large user group just yet.

    I’m learning symfony. I figured if it’s good enough for Yahoo’s Answers than it’s good enough for me. All the command line stuff gets time to get use to but. YAML rules. A big bonus of symfony is you don’t have to use their ORM. It’s also slow. Anyway, community is more helpful than Cake’s

  11. John says:

    Hey nice! I was looking for a lightweight PHP framework a little while ago, this probably would’ve been easier than rolling my own (which I did, perhaps naively). I had seen CodeIgniter a while back when I was looking at ExpressionEngine, but never checked it out.

    The framework I’ve “written” (it’s basically just a bunch of folders and a couple of includes) is entirely YAML based with no config at all, and very basic conventions. No database either. Pretty limited/limiting, but it’s also really transparent and definitely keeps out of the way. The idea is that, in many cases, my clients want a primarily static site they can update themselves, and getting a database involved is really overkill. So writing/reading from YAML (with a basic admin interface) is kind of a nice way to put together semi-static stuff. Bill-paying stuff, if you like ;)
    It’s called Seamonster, and I’ll probably post it up somewhere soon. Nice to see you at youtube/Jeremy’s, if only briefly!

Leave a Reply