Command Line Interface

Interesting use of the CodeIgniter routes is the given from the command line. Following the same formula of HTTP paths, with Luthier CI it is possible to define commands using a new syntax.



CLI routes must be defined in application/routes/cli.php.

For example:

# application/routes/cli.php

// Usando funciones anĂ³nimas
Route::cli('test', function(){ 
    echo 'Hello world!';

// Apuntando a un controlador existente
Route::cli('test2', 'foo@bar');

Accessing CLI routes

To access the CLI routes of your apllication, you must call the PHP interpreter from the command line in the index.php file of the root folder, separating with spaces each segment of the desired route:

$ php index.php [segment1] [segument2] ... [segmentN]

For example, the route:

Route::cli('greet/{name}', function($name){
    echo 'Hello ' . $name ;

It is accessed through the command:

$ php index.php make greet anderson

And the result will be:

Hello anderson

Built-in CLI Tools

As of version 0.2.0, Luthier CI comes with several tools for the command line to automatize some CodeIgniter tasks such as creating controllers, helpers, and migrations.

Write permissions
Make sure the application folder has write permissions for these commands to work properly
Only available for development
For security, these commands will be deactivated when the active environment of your application is testing or production.


To activate the CLI tools of Luthier CI, add the following to your CLI routes file:

# application/routes/cli.php

Luthier\Cli::maker();      // Comando 'luthier make'
Luthier\Cli::migrations(); // Comando 'luthier migrate'

"luthier make" command

The luthier make command allows you to generate a wide variety of framework files.


$ php index.php luthier make [resource] [name] [type?(sequenatial|date)=date]


  • resource is the type of resource (controller, model, helper, library, middleware or migration)
  • name is the name of the resource, and
  • type (in case of creating a migration) is the type of migration to generate.


// Creating a controller:
$ php index.php luthier make controller ControllerName

// Creating a model:
$ php index.php luthier make model ModelName

// Creating a library:
$ php index.php luthier make library LibraryName

// Creating a helper:
$ php index.php luthier make helper HelperName

// Creating a middleware:
$ php index.php luthier make middleware MiddlewareName

// Creating a migration (by default, migrations are created by date)
$ php index.php luthier make migration create_users_table
$ php index.php luthier make migration create_users_table date
$ php index.php luthier make migration create_users_table sequential

"luthier migrate" command

The luthier migrate command runs (or reverses) a migration.


$ php index.php luthier migrate [version?=latest]

Where version is the version of the migration to run. If omitted, it will proceed to migrate to the latest available version.

It is also possible to use one of these special commands as version:

  • reverse: reverse ALL migrations
  • refresh: reverse ALL migrations and then proceed to migrate to the latest available version


$ php index.php luthier migrate reverse
$ php index.php luthier migrate refresh