IAN ESCARRO

A Great Help for CodeIgniter 3

August 18, 2024

We know there's limited scaffold functionality for CodeIgniter 3. So this for our friends that are still using the  old CodeIgniter 3 framework. And most of cool friends will advice we move to Laravel for newer and modern applications. But we don't need to migrate anytime soon so why create small features for our legacy codes without the hassle of migrating the whole applications. And yes, there's CodeIgniter 4 but it's a new standard conforming framework so most of the codes will be a rewrite or a redo. So adding a new small feature will be a big diff for just a feature branch. And we all know it's a pain code reviewing huge diffs pull requests. And yeah, it's cost effective and efficient to just add the feature in CodeIgniter 3. And question arise, can we make it quick?

Yes we can. Introducing Ignite, it's a small generator for CodeIgniter 3. It can scaffold, or can generate individual components such as controller, model or views. It does differ from Rails scaffold since it's intended to be minimal and can just go on with improving the current applications being feature added to.

The usage. We can install it via composer. So imagine we will be adding a News feature in our current app, we can just execute the parameter "g" and scaffold parameter for News components.

php vendor/iescarro/ignite/g scaffold "news|date,content"

It should generate the component in app's controllers, doc (schema.sql), helpers, models, views components. And yes, we need to trim a bit of details especially in the SQL schema but it's just a matter of updating column types and we are now presented with at the most part, working news components. Personally, not liking CI3 migration scripts, so we'll do vanilla SQL.

Now, accessing /news we get the list, can add via Add News and can edit news with Edit link in the list. In about 3 seconds. Maybe 4 or 5 :) This greatly helps with eliminating a lot of typing so we can proceed to implementing the business logic that we need with our new feature implementation.

So good luck and hope the library helps with improving your workflow. Hit me up in the Github repo for questions and/or suggestions.

ABOUT IAN ESCARRO

Founded ICE Solutions.

Powered by cmsInferno with ❤️!