Again about my Matches CLI – a CodeIgniter CLI script

When I work on an existing CodeIgniter project, I usually just copy/paste from previous work: if I need to create a new controller, I simply copy an existing controller that looks similar to what I want to do in the new controller and paste it as the new controller. After that I delete what I don’t need (sometimes that means about 75% of the copied code).

Why do I do this? Because I simply need a template, a boilerplate from which to start creating new code. The same happens with models, views, etc.

But now and then I need to create a new project, and I find myself staring at an empty screen because I forgot how to start the file (the “copy/paste effect”).

So why not use an “artisan”, or an “oil”, or whatever for CodeIgniter. I mean why not simply create a php CLI script that would allow us to create a boilerplate for controller, models, views, etc. whenever we need.

We simply write inside the console: php index.php matches create:controller Welcome, and the controller is created for us to start coding.

Having this in mind I’ve written such a script some time ago, and found myself returning to it when I create a new CodeIgniter project.

You can also use it on its Github repository:

To install, you simply copy the files in their respective locations. After that, take a look inside the configuration file matches.php. Maybe you want to change something in there, who knows…

And you are ready to go. So open the console (command prompt), go inside your project (where the main index.php – bootstrapper – of your application is) and say hello to the Matches:

php index.php matches

If you are greeted by the new controller, then start using it:

For example this line below…

php index.php matches create:controller hello e=admin

…will create a controller named Hello that will extend Admin_Controller.

More info regarding the usage you can find on the Matches repository. Do give it a try and tell me your opinion or maybe anything else you think would be great to implement.


  1. I have a personal question related to CODEIGNITER and a modal window, can I ask for your help.

  2. This is what i need.
    Sometimes when i copied a new controller from another controller i forgot to change the class name so it’s return 404 when im trying to access from browser. 😀

  3. This is awesome!!!

    I’ve got these code templates in PHPStorm that does this exactly. BUT the problem happens when i’m managing a larger project which requires a larger developer base. Not all of us use the same IDE, so we cannot share these code snippets easily to help our development efforts. Anyway, this basically provides the same power I have in my IDE, but also extend this and easily share with my other developers. I’m definitely going to use this in my next project.


Leave a Reply

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

No spam? * Time limit is exhausted. Please reload CAPTCHA.