Should Zend_Console_Getopt become Zend_Controller_Router_Cli?

The default front controller route is not compatible with any class other
than Zend_Controller_Request_Http.
<http://framework.zend.com/manual/en/zend.console.getopt.html>
On 6/28/07, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:

-- 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/




--
Michael DePetrillo
[EMAIL PROTECTED]
Mobile: (858) 761-1605
AIM: klassicd

www.michaeldepetrillo.com

Reply via email to