CodeIgniter’s Built In Lameness

Don’t get me wrong.  I love CodeIgniter – the documentation and community are great.  The libraries are excellent.  I’m outsourcing development of a couple private projects, and I couldn’t trust anyone to code properly without the CodeIgniter framework/paradigm.

CodeIgniter recently dropped support for PHP4.  So we can expect quite a few improvements, but CodeIgniter will always be very limited.

The reason is that the whole framework is organized around the concept of a Singleton – $this.

Singletons have a very few uses, but otherwise are very, very, very bad.  Codeigniter is an example of this.

The reason is, Singletons assumes that you’re only ever going to need one – and when they’re wrong, it makes things very hard to expand.  CodeIgniter assumes you’re only going to need one controller.  And they’re wrong, of course.   Because of Singletons, Codeigniter can’t have a decent HMVC (hierarchical model-view-controller) implementation.

There are a couple libraries that claim to offer multiple controllers – Wick and Modular Extensions.  But BOTH break when you try to use any libraries that use PHP5 autoloading of models.  Ion_Auth dies if loaded in HMVC.  DataMapper DMZ dies if loaded in HMVC.

Posting on the CodeIgniter forums about wanting to load a controller within a view will get a visit from the MVC police.  “I don’t understand why you would want to…” is the most common response.

They’re idiots.

Look at any decent application or website of even moderate complexity, and you’ll see why multiple controllers are needed.

  • Facebook has ads and widgets all over the page.  Some are loaded via ajax too.
  • Xero has a great interface, but I pity the fool that wants to put all that in one controller.
  • Piwik is a great analytics application that allows multiple dashboards, and you can rearrange the way they show.

Kohana was based on the CodeIgniter concept, but is based on the factory method, not singletons.  So apparently it can handle HMVC easily.  The two things that stop me from using it:

  • Smaller user community (which means fewer people to outsource to)
  • Lack of documentation.
  • Lack of concern for backwards compatibility.

HMVC is the only real drawback in CodeIgniter as compared to Kohana.  Sure, the Kohana code is based PHP5 OO features while CodeIgniter is primarly PHP4 OO based.  But you can still get things done – except for HMVC.

No Comments

Post a Comment

Your email is never published nor shared.'Required fields are marked *

*
*