2009年9月30日星期三

[fw-mvc] creating a cli interface to mvc web app

I wanted to create a scriptable cli to a web app that we have have. One of the things that it does is that it kicks off a set of writing thousands of static html files.

I have something like the following:
$fc=Zend_Controller_Front::getInstance();
$fc->setControllerDirectory(array(
                     'default'=>$app.'/controllers/'));

Zend_Layout::startMvc(array('layoutPath' => $app.'/layouts/'));

$request=new Zend_Controller_Request_Simple('jt','generator');
$response=new Zend_Controller_Response_Cli();

$fc->setRequest($request);
$fc->setResponse($response);
$fc->throwExceptions(true);
Zend_Debug::dump($request);
$fc->dispatch();

but it gives me the following error: 
PHP Fatal error:  Uncaught exception 'Zend_Controller_Router_Exception' with message 'Zend_Controller_Router_Rewrite requires a Zend_Controller_Request_Http-based request object' in /data/sites/site/www/zf_source/library/Zend/Controller/Router/Rewrite.php:359

Do I need to call this upon the index.php that I have in my doc_root? 

I'm sure somebody has crossed this bridge so I greatly appreciate the help.

-jonathan


没有评论: