以命令行方式运行Zend Framework在linux中不起作用,但在Windows上可以


Running Zend Framework as CLI doesnt work in linux but does on Windows

我需要能够在linux (debian机器)上通过cron运行我的应用程序

因此,我创建了一个cron.php,它只加载我需要的相关引导内容。我还强制默认模块为'cron',而不是当前的默认模块。

运行cron:

cron.php action=[actionname] controller=[contollername]

我已经设置了一个路由器从cli中获取参数,并在我的应用程序中使用它。在我目前的情况下,它将强制操作和控制器是被要求的

$getopt     = new Zend_Console_Getopt (array ());
$arguments  = $getopt->getRemainingArgs();
.... set controller correctly using arguments 
.... do other stuff
$dispatcher->setControllerName($controller);
$dispatcher->setActionName($action);
$dispatcher->setParams($params);

当我在Windows上运行以下代码时,我得到了我所期望的,这是控制器和动作加载-按预期执行代码

c:'php -c [path_to_ini] -f cron.php action=send controller=mail

但是当我在Linux上运行完全相同的代码时,我得到一个奇怪的异常:

:~$ php -c [path_to_ini] -f [path_to_cron]cron.php controller=mail action=send
Exception Found:
    Name: Zend_Controller_Dispatcher_Exception
    Message:Cannot load controller class "IndexController" from file "[path_to_application]/modules/cron/controllers/IndexController.php'
Stack Trace:
0 [path_to_zend]/Controller/Dispatcher/Standard.php(262): Zend_Controller_Dispatcher_Standard->loadClass('IndexController')
1 [path_to_zend]/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Simple), Object(Zend_Controller_Response_Http))
2 [path_to_zend]/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
3 [path_to_zend]/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
4 [path_to_application]/public/cron.php(36): Zend_Application->run()

为什么Linux可能会加载与windows不同的控制器。我真是难倒了。

thanks in advance

附加运行状况说明:

转储控制器和动作在我的路由器中显示我正确地设置了控制器和动作在*nix和瞌睡。

我试着在/Zend/Controller/Dispatcher/Standard.php(262)中寻找,似乎在这一点上控制器已经改变了。

当某些东西在Windows上运行良好而不是在Linux上运行时,很可能是大写/小写不匹配的问题。我会先找这个;)

相关文章: