Nicotine

Open source framework for PHP & MySQL

Downloads Page

Console Commands

Synopsis: cd workspace/cli
php console <grup>:<command> [argument] [-option]

Crons and scripts

php console cron:cron-delete-inactive-users Execute cron cron-delete-inactive-users.php from the directory workspace/cli/crons.

Note that the file can be placed also in a subdirectory. In this case the, the command will be: php console cron:subdirectory/cron-delete-inactive-users

Directory separator is always / on any operating system. There is no need to specify file extension. It is by default .php.

php console script:import-csv-users Execute script import-csv-users.php from the directory workspace/cli/scripts.

Like for crons, scripts also can be placed into subdirectories.

Database

php console db:fresh Execute all the queries from the file workspace/db/db.sql. This will (or should) drop all existing tables, before re-creating them.

Clear logs

php console clear:log admin Clear log directory workspace/admin/logs

php console clear:log site Clear log directory workspace/site/logs

php console clear:log api Clear log directory workspace/api/logs

php console clear:log crons Clear log directory workspace/cli/crons/logs

php console clear:log scripts Clear log directory workspace/cli/scripts/logs

Note that .keep files inside log folders aren't deleted.

php console clear:logs Clear all logs.

Clear sessions

Keep in mind that in extremely rare cases it is necessary to delete saved server-side sessions. Anyway, if you need this at a given moment, execute the command: php console clear:sessions

Generating a controller

php console make:controller Orders -admin This will generare a prototype controller Orders.php in the workspace/admin/controllers folder.

For generating a site side controller, send -site option, instead of "-admin" option.

Generating a model

php console make:model ArticlesModel -site This will generate a prototype model ArticlesModel.php in the workspace/site/models folder. Note that the models are recommended to be suffixed always with "Model" word.

For generating an admin side model, send -admin option, instead of "-site" option.

Generating an API

php console make:api ImportOrders This will generate an API prototype script ImportOrders.php in the workspace/api folder.

Generating a cron

php console make:cron UpdateContent This will generate a cron prototype script UpdateContent.php in the workspace/cli/crons folder.

Generating a script

php console make:script OptimizeImages This will generate a script prototype OptimizeImages.php in the workspace/cli/scripts folder.

Generating a CRUD

php console make:crud Articles This will generate the controller workspace/admin/controllers/Articles.php and the model workspace/admin/models/ArticlesModel.php. You may need to edit these resources as you need.

Note that for every generator command, if the file already exists, the command will fail.