我正试图在zf2项目中制作一个cron应用程序,但它总是给我以下消息:
失败原因:无效参数或未提供参数
我的代码是:
module.config.php
'controllers' => array(
'invokables' => array(
'Sync'Controller'Cron' => 'Sync'Controller'CronController',
'Sync'Controller'Index' => 'Sync'Controller'IndexController'
),
),
'console' => array(
'router' => array(
'routes' => array(
'user-reset-password' => array(
'options' => array(
'route' => 'user resetpassword [--verbose|-v] <userEmail>',
'defaults' => array(
'controller' => 'Sync'Controller'Index',
'action' => 'password'
)
)
),
'cron' => array(
'options' => array(
'route' => 'cron [full|center]',
'defaults' => array(
'controller' => 'Sync'Controller'Cron',
'action' => 'full'
)
)
)
)
)
)
CronController.php
class CronController extends AbstractActionController
{
public function fullAction()
{
$request = $this->getRequest();
if (!$request instanceof ConsoleRequest) {
throw new 'RuntimeException('You can only use this action from a console!');
}
return("hi");
}
public function centerAction()
{
}
}
如果路径中有一个匹配的php
二进制文件,则可以从应用程序文件夹调用:
php public/index.php cron full
或者只是
php public/index.php cron
(由于路由默认为fullAction)