Codeigniter vs FuelPHP (Revisited)

Last updated: October 26, 2012

A while ago I wrote a blog post comparing Codeigniter with FuelPHP (a framework that was spurn from some popular Codeigniter developers), that article has since become outdated so I thought I would do a follow-up to my original post to see if anything has changed and the gap has been lessened between the two frameworks.

Since I wrote that post I’ve used FuelPHP for quite a few personal client projects in place of WordPress. I’ve also used Laravel and even attempted to revisit Kohana which I’ve never been a fan of in the time-frame since writing the original comparison.

Lets get to it, shall we?

HMVC Support

Codeigniter

Still no core support for HMVC and most likely will never support it as far as I can tell. The Modular Extensions HMVC library is a must have addition for adding module suppport to your Codeigniter applications. The annoying thing about having to use a third party library for HMVC functionality is when the framework is updated and you decide to upgrade to the newest version, core changes can mean third party libraries stop working.

FuelPHP

Comes with support for HMVC right out-of-the-box, it’s in the core. The beautiful thing about HMVC being bundled within the core is that upgrades will always support the modular functionality not to mention you’re not forced into using a modular architecture in your applications, it’s there if you need it and at the end of the day everyone loves to have options, right? Not everyone sees the benefit of a modular application, some people are fine with creating a non-portable application and FuelPHP offers that flexibility.

Documentation

Codeigniter

It’s a no brainer that Codeigniter has the easiest to understand but detailed documentation out of any framework. This has always been Codeigniter’s strength and to this day, has been its number one selling point/advantage for attracting new developers.

FuelPHP

A lot has changed in regards to FuelPHP documentation, when I wrote my original post some parts of the framework weren’t documented and some of the parts that were, didn’t clearly explain certain aspects of what you were reading. The documentation has improved quite a lot, including a nice new design and navigation structure that makes navigating the documentation easier. The incomplete parts have since been filled, however the documentation still doesn’t feel as robust as Codeigniter’s (the gap is definitely closing).

Object Relational Mapping / Database Abstraction

Codeigniter

While not as powerful as a full-blown ORM, Codeigniter comes with a decent database query builder that allows you to build database queries in an object oriented way. However when it comes to complex sub-queries and joining multiple tables together, for a new or intermediate developer this can be a daunting task to achieve. Codeigniter allows you to do a join in the form of $this->db->join() however it can get quite messy when you need to join more than one or two tables together.

If an ORM is what you’re after, Datamapper for Codeigniter is definitely a convenient addition. Another good choice is Redbean ORM which is developed with any PHP application in mind regardless of framework (and runs off of one class).

FuelPHP

Bundled with FuelPHP is a powerful ORM class that offers a cleaner way of interacting with a database in comparison to Codeigniter’s simple database class which you realise after using pales in comparison to an ORM. Having said that, ORM’s aren’t for everyone and some people are actually against them.

Naming Conventions and Restrictions

Codeigniter

As free as Codeigniter likes to think it is and don’t get me wrong it’s pretty loose with how it lets you code, it definitely has some downsides. You can’t have a controller and model of the same name otherwise you will encounter a naming collision. This is where you realise the true purposes of namespaces, being able to group multiple classes of the same name within different namespaces to prevent collisions.

FuelPHP

Go nuts, have a controller or model use the same class name. FuelPHP fully supports namespaces and while many people like to think they don’t really matter if you’re content with appending an m after your model name to prevent a collision, appending an extra character to a model name after using feels unnecessary after using a cleaner namespaced approach like FuelPHP offers.

Automagic

Codeigniter

Unless otherwise added in, Codeigniter offers no form of autoloading of classes used in the framework. The closest aspect of Codeigniter that offers some kind of autoloading (nothing magic about it) is the ability to specify an array of helpers, drivers, config files, models and libraries to automatically load in the config/autoload.php file.

FuelPHP

Using static methods quite extensively you don’t need to load a class before using a method inside of it. To initiate a form open tag you merely have to go Form::open(‘formurl’) in comparison to Codeigniter requiring the form helper being loaded and then having to go form_open(‘formurl’) it’s perhaps a minor detail but if you’re using 5 different helper functions located in 5 separate files just to use the function once, using them statically in FuelPHP has its advantages. It’s also worth noting that class methods can be called by instantiating a class object, but mostly all classes support static calls.

Authentication / Templating

Codeigniter

Many Codeigniter purists like to argue that the lack of authentication and decent template parsing engine is irrelevant, I tend to disagree. While Codeigniter has enjoyed critical acclaim and a large massing of passionate followers without the addition of an authentication library or decent template engine I think it certainly matters. Searching Github for an authentication library reveals that everyone has written their own auth library (I’ve even written a couple of them myself), the same scenario also applies for templating engines (I even wrote a Smarty 3 parser addon for Codeigniter).

The downside to not having an authentication library especially creates a security hazard. If you’re using a third party library it most likely hasn’t been tested potentially opening up your application for all kinds of attacks. A core version of an auth library wouldn’t necessarily make your application safer, but if the framework contributors were responsible for its development it would most likely be more security conscious and actively patched in comparison to other choices.

FuelPHP

Decimating Codeigniter in the process, FuelPHP not only ships with a driver based authentication library it also comes with a decent templating engine as well. Both modules for FuelPHP not only provide pretty convenient functionality out-of-the-box they also allow you to extend them easily. After using the authentication class in FuelPHP you feel cheated when going back to Codeigniter, sometimes such a trivial feature can make such a big difference.

Extending / Overriding

Codeigniter

Codeigniter does a very good job at allowing you to override & extend core files, but makes you have to use a predefined user prefix you need to apply to your classes. To override the parser class for example you need to create a class called MY_Parser (if you kept the default prefix as “MY_”). While this works, it feels like more of a hack due to the PHP4 support.

FuelPHP

Everything can be extended. Rather than repeating what has already been perfectly said elsewhere, the FuelPHP documentation does a great job explaining how you can extend the core of FuelPHP here http://docs.fuelphp.com/general/extending_core.html – as you can see it’s a lot more proper and cleaner than using hackish PHP 4 prefixes on classes.

The Community

Codeigniter

The Codeigniter community is pretty massive, but having said that I’ve noticed since writing my original article the number of newbie threads on the Codeigniter forums have increased and the number of long-standing experts who know the framework quite well have decreased. This isn’t to say the community is becoming weak or slowly breaking down, people like Phil Sturgeon are still out and about (amongst others), but it does feel like the forums have become a place for spam, broken English and noobish questions the documentation answers.

FuelPHP

When I wrote the original comparative post, the FuelPHP community was still growing but nowhere near the size and stature of the Codeigniter community. Things have somewhat changed since then, the forums for FuelPHP have become more active, professionals of the framework are always around to answer questions and the amount of static on the forums doesn’t appear to be as high. Having said that, it feels like the community still has some growing up to do, is it a selling point of the framework? Not solely, a big community does tend to make people feel more inclined to use something because there are more people to ask but the documentation is better and asking a question on Stack Overflow is certain to garner a response.

Third Party Additions and Projects

Codeigniter

There are a lot of third party additions for Codeigniter, most of them are authentication libraries people have created, template parsers and scripts for accessing third party API’s. Because of the age of Codeigniter, there are more third party additions and open sourced projects on Github alone built on Codeigniter because it’s a proven framework that serves its purpose quite well. Having said that, a search on Github and Bitbucket will reveal a lot of outdated libraries for Codeigniter written prior to the 2.0 days, while some of them still surprisingly work with minimal tweaks, most of them are outdated and insecure: tread lightly.

FuelPHP

The number of projects built using FuelPHP has steadily increased since writing the original post. A Github search reveals some well-built CMS’s, even better authentication libraries, scripts for accessing API’s and other cool additional addons for your FuelPHP application. Due to the age of FuelPHP (it’s edging close to 3 years of age now), the number of outdated libraries and applications is quite low so there is a good chance an application or library you come across is still a great learning point for understanding how the framework works or implementing additional functionality.

FuelPHP is getting close to a 2.0 version which is a complete rewrite from the ground up which means there are most likely going to be a lot of orphan projects and scripts lying around after it’s released and 2.0 becomes the norm. It’s reasons like this people stick with Codeigniter, nothing ever really changes or forces you to rewrite your application even the jump to the 2.0 version of Codeigniter required minimal changes to get your applications working with it. If you don’t mind living life on the edge, then you’ll be okay with FuelPHP’s changes.

The Learning Curve

Codeigniter

If you already know PHP, you know Codeigniter. The learning curve for even a newbie PHP developer is actually quite low. The great documentation in combination with the simple file system makes Codeigniter one of the most attractive PHP frameworks around.

FuelPHP

In my original post I made it known that I felt like FuelPHP has a slightly higher learning curve due to all of the awesome PHP 5.x functionality it supports like namespaces and more specifically having to remember the slashes and whatnot. While I still feel as though learning namespaces is an additional step for a PHP developer who might not have used them before, I’ve come to the realisation this additional step although adding to the learning time isn’t really much of a con and from what I’ve seen you can use FuelPHP without using namespaces (although it’s advisable to use them if you want to harness the true power of FuelPHP). The learning curve of both frameworks (FuelPHP is based on a similar structure to Codeigniter) is about the same in the end.

PHP Compatibility

Codeigniter

This is slowly changing, but Codeigniter has long prided itself on supporting not only PHP5 but also PHP4. Many like to hate on Codeigniter calling it out of date and bloated with legacy code but fail to understand some people are still running PHP 4 (especially the enterprise sector), not everyone jumps onto newer versions of everything because sometimes the older version of something is more supported and tested, Python is a great example of a language which has struggled to on-board users to the 3.0 version due to lack of third party libraries catching up with support.

FuelPHP

The cool kid on the block, the kid that is skipping class and smoking cigarettes in the boys toilets. Because FuelPHP is a relatively new player in the framework scene, it skipped that whole we need to support PHP4 phase of the Internet and was able to come out swinging with full support for PHP5’s juicy features like anonymous closures, late static binding and namespaces something that Codeigniter won’t support for a very long time (most likely never truly support). FuelPHP isn’t the only framework to support PHP5, but if you’re after a framework that is as simple as Codeigniter but is a little more modern, FuelPHP is your best bet.

Conclusion

At the end of the day, it’s all about taste. If lack of authentication library, ORM and PHP5 functionality is something that concerns you then FuelPHP is probably the ideal choice. If you need to build an application that needs to work not only in a PHP5 setting but also a PHP4 setting like the enterprise sector that isn’t changed all too often then Codeigniter is probably your best bet.

I’ve used both frameworks quite extensively, Codeigniter more-so than FuelPHP but from the year or so of using FuelPHP I’ve come to use it for my many startup ideas because I control the server environment and an application I’ve been building since 2007 uses Codeigniter because I will be selling it to average Joe’s and businesses who might have invested in PHP4 infrastructure due to its reliability and maturity which I understand and accept or perhaps not being able to afford the luxury of a team of system administrators or suffering downtime as a result of an upgrade to PHP5.

Both frameworks can accomplish anything you want to do in a web application, FuelPHP does a lot of heavy lifting for you and Codeigniter requires you to work a little harder (especially if you want authentication in your application) but at the end of the day they both are frameworks. You can hammer a nail into a piece of wood using a rock or you can use a hammer, both get the job done.

 

Dwayne

 

9 thoughts on “Codeigniter vs FuelPHP (Revisited)

  1. Nice article. About the vast amount of auth libraries for CodeIgniter, “Ion Auth” seems to be the most popular choice I’ve seen lately. I’ve used it in pretty much all of my projects with CodeIgniter and it works quite well. I wish it were lighter, as it features groups and logging login attempts, needing three database tables, which feels a bit bloated.

  2. Great article, you really covered everything! You mentioned in the first section that you have been using Laravel. I would love to see your write up on that in everything that you covered above.

  3. Fair comparison. I’ve been using Codeigniter since 2006 and I’m glad to hear of the differences you found in FuelPHP. I was watching it while they were first building it but stuck with Codeigniter.

    The company I’m working for uses Kohana 2.X and an old version of Symfony. I definitely like going home to Codeigniter at the end of the day.

    I’ll have to give Fuel a closer look!

  4. For the record, I do understand that there are like millions of lines of code written for CI. I myself have used CI for a year, and I thought it was great.

    But I will never advice anyone to use CI nowadays. It really is very old. Enterprise sector might be using PHP4? Ok, I’m fine with that. I’m not working for the enterprise. Also I don’t get how can an independent developer use a framework that in currently developed new version (3.0) supports 5.2.x when php devs are about to partially drop support for 5.3 already? (read this in php mailing list, it’s just a thought, but anyway, thoughts will sooner or later lead to actions).

    Aside from that, using CI now is just boring. Especially using it for a long time (for me a year was enough; after 6 years… would hate it already, I guess 🙂 ).
    But Fuel v.1.x isn’t that great too – it misses many small and not-so-small things. So I’m waiting for stable versions of Fuel 2, Yii 2 and Laravel 4 (Fuel can be dropped from this list though). Also wanna try out Symfony 2, but will have no luck using it at current job.

    PS. You were saying that it can be ‘a bit too much to understand’ FuelPHP. What about Symfony 2 or Laravel 4 then? A programmer must always learn, considering that namespaces, for example, aren’t the hardest thing to understand.

  5. Although I am inclined to agree, part of me will always have a soft spot for Codeigniter. It was the first PHP framework that I learned to use that wasn’t the behemoth Zend. I agree that Codeigniter is starting to feel more and more dated with each passing day, it still gets the job done though even if you have to carefully name libraries and models to ensure no clashes due to lack of namespace support.

    FuelPHP is a nice bridge framework for a Codeigniter developer. Structure is mostly the same, learning curve is mostly the same and the documentation is getting quite robust. Kohana is probably one of the worse frameworks with exception for Zend that I have ever used, same goes for CakePHP.

    Symfony 2 is a really nice framework, I haven’t built anything with it myself but have worked on a couple of applications that were built on it and I liked what I saw. I adore the way the framework is a combination of a multitude of open source PHP libraries like Propel and Doctrine, Twig for templating, Swift Mailer and PHPUnit as well as some awesome Symfony components as well.

    I am a big fan of Symfony and recently Laravel as well. I am looking forward to version 4 of Laravel, I think it’s really going to shake things up in the PHP framework community, the feature-set is super impressive and it’ll either result in the dropping of Codeigniter from my day-to-day and potentially FuelPHP, I am anticipating that I’ll eventually move onto Laravel in the end as will most developers.

    The playing field is definitely changing, PHP is becoming a more serious framework thanks to some helpful developers creating these powerful frameworks and making our lives easier. Having said all of that I’ve been playing around with Ruby and Ruby on Rails recently and have found it really easy to understand thanks to the fact that Codeigniter is modelled off of Rails, so I might completely move away from PHP to Rails eventually, but most likely never completely.

  6. Hi!,

    Nice article. I share your ideas. Codeigniter is becoming so old for this times. I’m building mobile apps with it and i need more.

    I have the next month to learn FUELphp, i think that this is my last bet.

    Thank you, and sorry for my english.

  7. Hi!

    I just wanted to mention that CodeIgniter 2.0 dropped support for PHP 4, and we’re at CodeIgniter 2.1.3 right now.

    Perhaps the GoPHP 5 initiative had a significant role in getting projects to stop supporting PHP 4 to get web hosting providers to finally make the move, but I don’t really know the historical PHP events in chronological order to tell you for certain 🙂

  8. @pablo
    > I’m building mobile apps with it and i need more

    When I see such comments, I always wonder – what is this «more» that you cannot absolutely achieve with Codeigniter?

Leave a Reply

Your email address will not be published. Required fields are marked *