Edit app/webroot/index.php and change the lines that read like :
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { } else { $Dispatcher=new Dispatcher(); $Dispatcher->dispatch($url); }
to something like :
// if this is a favicon request, do nothing if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') : // if this is a command line call, dispatch it with the argument elseif (php_sapi_name() === "cli") : define('CRON_DISPATCHER',true); $Dispatcher=new Dispatcher(); $Dispatcher->dispatch($argv[2]); // dispatch normally else : $Dispatcher=new Dispatcher(); $Dispatcher->dispatch($url); endif;
You can then call the action from the command line using something like :
$ php ./app/webroot/index.php /mailer/processIncomingMail
Check if the _CRON_DISPATCHER_ constant is set in your controllers if you need to know the origin of a request.
(courtesy of the bakery)
No Responses to “Cake actions from the terminal”
Leave a Reply