API documentationTable Of ContentsPrevious topicNext topicThis Page |
Console¶Console allows to run some commands for remote purpose. To run console manager, you will need to move into website root directory and execute: php public/index.php command param1 param2
Usage¶To use command simple type command and/or sub commands if required: php public/index.php database update
Some commands have aliases: php public/index.php db update
To show all available commands you can type: php public/index.php
## or ##
php public/index.php help
Help can be used for command: Or sub command: Commands¶
Command Creation¶Command can be created in module. Special directory “Command” must be placed in module root. Command example: <?php
/**
* Assets command.
*
* @category PhalconEye
* @package Core\Commands
* @author Ivan Vorontsov <ivan.vorontsov@phalconeye.com>
* @copyright 2013-2014 PhalconEye Team
* @license New BSD License
* @link http://phalconeye.com/
*
* @CommandName(['assets'])
* @CommandDescription('Assets management.')
*/
class Assets extends AbstractCommand implements CommandInterface
{
/**
* Install assets from modules.
*
* @return void
*/
public function installAction()
{
$assetsManager = new Manager($this->getDI(), false);
$assetsManager->installAssets(PUBLIC_PATH . '/themes/' . Settings::getSetting('system_theme'));
print ConsoleUtil::success('Assets successfully installed.') . PHP_EOL;
}
}
Each command must be extended from AbstractCommand and implements CommandInterface. Commands metadata defined via class annotations: <?php
/**
* @CommandName(['commandname', 'commandalias'])
* @CommandDescription('Description of the command.')
*/
class SomeCommand extends AbstractCommand {}
/**
* Command can gave initialization method, that will be performed before any action.
*
* @CommandName(['commandname', 'commandalias'])
* @CommandDescription('Description of the command.')
*/
class SomeCommand extends AbstractCommand {
public function initialize() {}
}
/**
* To define sub command - add subcommandAction method. It will be automatically added as sub command.
*
* @CommandName(['commandname', 'commandalias'])
* @CommandDescription('Description of the command.')
*/
class SomeCommand extends AbstractCommand {
public function subcommandAction() {}
}
/**
* Parameters of sub command automatically takes as parameters of it.
* NOTE: action with parameters must be commented well, coz this will be a description of this commands!
*
* @CommandName(['commandname', 'commandalias'])
* @CommandDescription('Description of the command.')
*/
class SomeCommand extends AbstractCommand {
/**
* Test action with params.
*
* @param string|null $param1 Param1 - string. Example: "string".
* @param bool $param2 Param2 is flag.
*
* @return void
*/
public function testAction($param1 = null, $param2 = false) {}
// Help for this command will looks like this:
//Help for "commandname test":
// Test action with params.
//
//Available parameters:
// --param1=NULL (string|null) Param1 - string. Example: "string".
// --param2 Param2 is flag.
}
|