\Disco\classesConsole

Bridge for executing CLI requests.

Its used by calling public/index.php via the CLI and passing an arguement(s). Each method is actually a command eg php public/index.php with Crypt hash 'kitty kat'.

Extend it by calling \Disco\classes\Console::extendConsoleWithClass(new \YourClassName) prior to setting up the framework in public/index.php. Each class that extends this class (the Console) will have its public methods made available for execution directly from the CLI. For example if you extended this class with a class that had a public method doOurReallyBigJob that method can be executed by calling php public/index.php doOurReallyBigJob or even 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').

Summary

Methods
Properties
Constants
extendConsoleWithClass()
__construct()
postInstallCmd()
with()
jobs()
killJob()
gen()
devMode()
maintenanceMode()
dbBackupStructure()
dbBackup()
dbRestore()
create()
yesOrNo()
consoleQuestion()
consolePrompt()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
getDBSchema()
$extendedCommands
N/A

Properties

$extendedCommands

$extendedCommands : array

Type

array — Holds classes that extend the functionality of the Console.

Methods

extendConsoleWithClass()

extendConsoleWithClass(\StdClass  $class) 

Extend the default console commands with other classes.

Parameters

\StdClass $class

The class to extend the console functionality with.

__construct()

__construct() 

Call the appropriate method of the class based on the arguements passed to the CLI.

Passes all arguemnts to the appropriate method via an array.

postInstallCmd()

postInstallCmd() 

Run after install via composer.

with()

with(array  $args) 

Execute a class/service/facade and method.

eg: `with Cache set cache-key 'Some Value' 60

Parameters

array $args

The arguements.

jobs()

jobs() 

View the queued jobs.

killJob()

killJob(array  $args) 

Kill a queued job by passing the PID.

eg: kill-job 203949

Parameters

array $args

The arguements.

gen()

gen(array  $args) 

Generate a secure key for use in cryptographic methods, optionally setting it in `app/config/config.php`.

eg: gen aes set eg: gen sha 32 set-lead eg: gen sha 32 set-tail

Parameters

array $args

The arguements.

devMode()

devMode(array  $args) 

Get the current dev mode, optionally setting it.

eg: dev-mode eg: dev-mode true eg: dev-mode false

Parameters

array $args

The arguements.

maintenanceMode()

maintenanceMode(array  $args) 

Get the current maintenance mode, optionally setting it.

eg: maintenance-mode eg: maintenance-mode true eg: maintenance-mode false

Parameters

array $args

The arguements.

dbBackupStructure()

dbBackupStructure(array  $args) 

Create a new backup of the DB structure.

eg: db-backup eg: db-backup /app/db/ eg db-backup /app/db/ BACKUP.sql

Parameters

array $args

The arguements.

dbBackup()

dbBackup(array  $args, boolean  $structureOnly = false) 

Create a new backup of the DB. 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`.

eg: db-backup eg: db-backup /app/db/ eg db-backup /app/db/ BACKUP.sql

Parameters

array $args

The arguements.

boolean $structureOnly

Whether to backup only the structure.

dbRestore()

dbRestore(array  $args) 

Restore the DB from a backup.

eg: db-restore eg: db-restore /app/db/ eg db-restore /app/db/ BACKUP.sql

Parameters

array $args

The arguements.

create()

create(array  $args) 

Create a model or a record. Use the special keyword `all` in place of a table name to generate records or models for all tables.

eg: create model user eg: create model user /app/config/model.format /app/model/

eg: create record user eg: create record user /app/config/record.format /app/record/

Parameters

array $args

The arguements.

yesOrNo()

yesOrNo() : boolean

Prompt the user at the console to supply a `Y` or `N` value.

Returns

boolean

consoleQuestion()

consoleQuestion(string  $question, array  $options) : mixed

Prompt the user at the console with a question and the valid options that serve as an answer to that question.

Parameters

string $question

The question being asked.

array $options

The possible answers to the question being asked, where the keys are the anwsers and the values are the description of the answer.

Returns

mixed —

The selected key from $options param.

consolePrompt()

consolePrompt(string  $question, boolean  $cannotBeBlank = false) : string

Prompt the user at the console to enter a free form text response to a question.

Parameters

string $question

The question that needs a response.

boolean $cannotBeBlank

The response to the question cannot be blank.

Returns

string —

The response to the question.

getDBSchema()

getDBSchema() : \PDOStatement

Used to get the database schema for building all models and records.

Returns

\PDOStatement