-- Xavier Vidal Piera <[EMAIL PROTECTED]> wrote
(on Thursday, 28 June 2007, 01:48 PM +0200):
> I have an Action which I want to run from a cronjob.
>
> Which is the best way to go?
> Calling the URL with curl or something like that?
> Or use the PHP-CLI?
>
> I don't know how to call the action with PHP-CLI.
There are a couple options. First, you can re-create your bootstrap, but
instead of letting the front controller create the request, you'd create
it yourself:
<?php
// .. setup bootstrap...
// Setup request:
// Provide the URL which you'd normally call for the action:
$request = new
Zend_Controller_Request_Http('http://host/controller/action');
// Use a CLI response, so that redirects won't throw exceptions:
require_once 'Zend/Controller/Response/Cli.php';
$response = new Zend_Controller_Response_Cli();
// Dispatch:
$front->dispatch($request, $response);
The other option is to use the CLI request object, which is currently in
proposal form; search on the wiki for Zend_Controller_Request_Cli. This
request allows you to specify a controller and action on the command
line, which would allow you to create a single CLI bootstrap and use it
to call any action in your application.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/