Hello Friends,
Sometime we need to run some background tasks using cakephp without user interaction or delayed response to user from server.
For this we can use CAKEPHP AppShell utility.
Syntax:
/path/to/cake/console/cake -app /path/to/app/ <shell> <task>
Example:
Create the Shell Skeleton
File: app/Plugin/Custom/Console/Command/ExampleShell.php
App::uses('Shell', 'Console');
class ExampleShell extends AppShell {
/**
* Default (no argument) method, inform the console of available commands
*
* @return void
*/
public function main() {
$this->_renderHeader();
$this->out(' Usage:', 1);
$this->out(" * <info>run</info> - Processes the tasks immediately.", 1);
}
/**
*
* @return void
*/
public function run() {
//your code here
}
}
Command: app/Console/cake Custom.Example run
0 Comment(s)