我试图在我的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()
{
}
}
答案 0 :(得分:0)
鉴于路径中有匹配的php
二进制文件,您可以从应用程序文件夹中调用:
php public/index.php cron full
或只是
php public/index.php cron
(因为路由默认为fullAction)