Codeigniter vs FuelPHP (Revisited)

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.