Command Line Interface (CLI)

Call your `index.php` file via the command line to execute commands that tweak, monitor, and build components for your application.

When you call your `index.php` file via CLI, your application will get constructed and have the `setUp` method called, it will then execute the appropriate command via the class `\Disco\classes\Console`.

Script usage:

php public/index.php [task] [[options],...]

You can extend the Consoles functionality with your own by calling

\Disco\classes\Console::extendConsoleWithClass(new \YourClassName)

prior to setting up the framework in public/index.php. Each class that extends the Console will have its public methods made available for execution directly from the CLI. For example if you extended the Console with a class that had a public method doOurReallyBigJob() that method can be executed by calling

php public/index.php doOurReallyBigJob
php public/index.php do-our-really-big-job

Any arguments that come after the first parameter will be passed to the method in an indexed array. So for example you call

php public/index.php doOurReallyBigJob 1552 test

the method doOurReallyBigJob will be passed an array as the first argument that will contain these values Array(1552,'test').

Config Commands #

// Change the DEV_MODE configuration variable
php public/index.php dev-mode [true|false]
php public/index.php dev-mode // print the current dev mode


// Change the MAINTENANCE_MODE configuration vairable
php public/index.php maintenance-mode [true|false]
php public/index.php maintenance-mode // print the current maintenance mode


// Generate & Set AES secrets
php public/index.php gen aes // prints the generated 32 length secret
php public/index.php gen aes set // generates a new AES_KEY256 secret and sets it in app/config/config.php


// Generate & Set SHA secrets
// Options : php public/index.php gen sha [length] [set]
php public/index.php gen sha 12 // print the generated sha secret of length 12
php public/index.php gen sha 12 set // Generates a new SHA512_SALT secret and sets it in app/config/config.php

Status Checks #

// Jobs stats
php public/index.php jobs

// Kill job
php public/index.php kill-job [job-#]

Call a Service or Class Method #

// You can call methods on any autoloaded class in your application with the with command
// Syntax:
// php public/index.php with [ [ClassName] [method] [arg0] [arg1] [arg2]...]

// For example the DB Service
php public/index.php with DB query 'SELECT name FROM user WHERE id=?' 203


php public/index.php with 'App\service\User' bannedCheck 


php public/index.php with 'App\cron\Job' doWork 'String variable passed to job method'  


php public/index.php with 'App\Console' yourConsoleCommand 'some/path' true

Creating Models #

// Use the CLI to create your Models for you
// Syntax:
// php public/index.php create model [table_name|all] [format_template_file_path] [output_directory]
//     - format_template_file_path defaults to `app/config/model.format`
//     - output_directory defaults to `app/model/`

php public/index.php create model user

php public/index.php create model all

php public/index.php create model user 'app/config/my-model.format' 'app/model/'

If a model already exists when the CLI attempts to write it out it will ask you if you want to overwrite the file.

Creating Records #

// Use the CLI to create your Records for you
// Syntax:
// php public/index.php create record [table_name|all] [format_template_file_path] [output_directory]
//     - format_template_file_path defaults to `app/config/record.format`
//     - output_directory defaults to `app/record/`

php public/index.php create record user

php public/index.php create record all

php public/index.php create record user 'app/config/my-record.format' 'app/record/'

If a record already exists when the CLI attempts to write it out it will ask you if you want to overwrite the file.

Database Backup & Restore #

// Backup your database
// Syntax:
// php public/index.php db-backup [storage_directory] [output_file_name]
//     - storage_directory default is `app/db/`
//     - output_file_name default is your database schema name
php public/index.php db-backup
php public/index.php db-backup `app/db-backup/` `DB_BACKUP`


// Backup your database structure
// Syntax:
// php public/index.php db-backup-structure [storage_directory] [output_file_name]
//     - storage_directory default is `app/db/`
//     - output_file_name default is your database schema name with `_STRUCTURE` appended
php public/index.php db-backup-structure
php public/index.php db-backup-structure `app/db-backup/` `DB_BACKUP_STRUCTURE`


// Restore your database
// Syntax:
// php public/index.php db-restore [storage_directory] [input_file_name]
//     - storage_directory default is `app/db/`
//     - input_file_name default is your database schema name
php public/index.php db-restore
php public/index.php db-restore `app/db-backup/` `DB_BACKUP`

If you want to alter the default dumping behavior create a configuration file at app/config/db-backup-settings.php and return an array with the settings you want to alter. The full list of settings can be found at https://github.com/ifsnop/mysqldump-php#dump-settings . By default if you do not specify a value for add-drop-table it will be set to true.