Porting Active Record to CodeIgniter
While I may still call myself a web designer, I very rarely dive into Photoshop these days—in fact, for the last year or so I have been almost exclusively dealing in either JavaScript or PHP. My productivity in the latter has been greatly enhanced by my adoption of the CodeIgniter framework for large projects, such as the bespoke CMS I recently finished building for local agency Digital Spoke.
While I generally find the Model-View-Controller pattern implemented by CodeIgniter to be very much in line with my way of thinking, when I recently discovered Ruby on Rails I was impressed by (to my mind) the much more natural way it implemented Active Record. So, I sat down and built a Rails-like Active Record implementation for CodeIgniter, and now—as I start another bespoke CMS project—I can say that it has made development even faster than it was before. Removing the need to write CRUD functions for every table, plus the flexibility of one-to-one model/table mappings, makes prototyping incredibly easy, and the natural language functions make the code easier to follow, making maintenance easier in the long term.
If you’re a CodeIgniter user too, let me know what you think.
Filed under: PHP.
Technorati tags: php ruby on rails codeigniter active record
Bookmark this article with del.icio.us
Previously: A thousands renderer for the Ext Grid control
Next: Tumbling
Comments
- Derek Allard
- 286 days ago
Matt… this is looking very, very (very) slick. I’m keeping an eye on this, and with any luck it will evolve into one of the defacto “go to” libraries.
Thanks, sincerely, for this contribution.
- #2
- Matthew Pennell
- 286 days ago
Thanks, Derek—like anything really useful, it grew out of a practical need on my current project.
Snook tells me to try CakePHP because it already has this kind of Active Record functionality baked in, but I’d rather improve CI. ;)
- #3
- Derek Allard
- 284 days ago
Yeah, he’s right. AR is one area where cake is um… am I allowed to say “better” without looking like a turncoat?
Anyhow, AR is getting some work in upcoming CI, particularly as we move EE into tighter integration, so tell Snook to enjoy the brief lead while he has it ;)
Your work, and our and the rest of the community should keep it brief!
- #4
Thanks for the contribution to the CodeIgniter community, and for the superbly written documentation. As all of my websites now are on the CodeIgniter framework, I am anxious to try your Rails-inspired ActiveRecord class.
I’ll give you some feedback when I do.
Cheers!