Zend_Console_Getopt is intended to be a class that parses command-line
options; it is not an application framework.
MVC is a very good solution for application design, but it's not the
only solution. Zend_Console_Getopt should remain decoupled from the MVC
pattern, so command-line options can be parsed for applications that do
not use the MVC pattern.
It would be fine to develop another class Zend_Controller_Router_Cli.
It would certainly make sense for this new class to utilize
Zend_Console_Getopt, but it is not *part* of Zend_Console_Getopt.
Regards,
Bill Karwin
________________________________
From: Michael Depetrillo [mailto:[EMAIL PROTECTED]
Sent: Saturday, June 30, 2007 7:02 PM
To: [email protected]
Subject: Re: [fw-general] Calling actions from PHP-CLI
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