Two CodeIgniter libraries I can not live without

Standard

I have said it before and I say it again – “Hi, my name is Andreas and I am a CodeIgniter junkie”. I can quit my CodeIgniter (a PHP framework) habit whenever I want, but why would I want to (read Why I fell for CodeIgniter to know more)?

For the last few CodeIgniter projects (begagnadebarnkläder.nu – hitta billiga barnkläder for example) I have used two libraries that have made my life as a developer much easier and that I really recommend anyone using CodeIgniter take a serious look at. Those libraries are IgnitedRecord and BackendPro. They are not brand new, but they sure get the work done!

IgnitedRecord
IgnitedRecord is a ORM library that makes interacting with the database so much easier. Especially handling relationships between tables much easier to deal with, an example is getting all posts a user has written in a blog:

$posts = $user->related('posts')->order_by('name', 'desc')->get();

Nice and clean and very easy to setup, all you need to do is to have your models extend IgnitedRecord and then define the relationships in the model. Some other goodies are that it is very easy to make subqueries and nested WHERE statements.

Instead of going in to all the details here I think you should go and download IgnitedRecord straight away and get started, it will save you time.

BackendPro
Almost every project needs some kind of administration backend. With some frameworks (Django) you get this out of the box, not so with CodeIgniter unfourtunatly. BackendPro gives you that and so much more – it also helps out with things like user authentication and access rights, asset management, breadcrumbs, preference handling etc. Only the fact that it is an easy to setup and then handles basic user authentication (such as login, registration and forgotten password) is well worth the price of admission (which is nothing since it is all free). BackendPro also comes with the excellent Matchbox library, which lets you organize your code into modules.

Combining the two
Unfourtunatly the two do not fit perfectly together since BackendPro uses CodeIgniters standard database libraries, so if you need to do any database work with BackendPro itself you need to remember not to use IgnitedRecord. Getting the two libs to play nicely once they are installed is quite straight forward though…

  • Move the ORM() function from system/application/libraries/MY_Loader (a IgnitedRecord file) to system/application/libraries/Loader (a BackendPro file).
  • Delete the MY_Loader file
  • Optionally you could autoload the IgnitedRecord library
  • To make it all work I had to make a file called ignitedrecord.php in system/application/libraries that includes ignitedrecord/ignitedrecord, as per http://codeigniter.com/forums/viewthread/104123/#548669.

Do you have any other favorite libraries for CodeIgniter? Please let me and everybody else know in the comments!

4 thoughts on “Two CodeIgniter libraries I can not live without

  1. Hey, thanks for the links and for the article. But i’ve found a broken link in your article. please check src of the BackendPro link. it missing “h” charecter.

Comments are closed.