【问题标题】:Zend Framework 2 Console RoutesZend Framework 2 控制台路由
【发布时间】:2012-09-02 12:41:28
【问题描述】:

我正在尝试为我的 ZF2 应用程序定义一些控制台路由,如此处所述http://packages.zendframework.com/docs/latest/manual/en/modules/zend.console.routes.html

在我的模块配置中:

'console' => array(
    'router' => array(
        'routes' => array(
            'user-set-password' => array(
                'options' => array(
                    'route' => 'user password <username> <password>',
                    'defaults' => array(
                        'controller' => 'User\Profile',
                        'action' => 'setpassword'
                    ),
                ),
            ),
        ),
    ),
),

但它似乎永远不会匹配路由,因为它总是打印使用信息。也不会匹配像“测试”这样的简单路线。 (当我在路由参数中写一些废话时,执行失败并显示Zend\Mvc\Router\Exception\InvalidArgumentException,因此在加载模块时它会识别控制台路由)

是我的错还是最新的 zf2 版本中的错误?

【问题讨论】:

    标签: php console zend-framework2


    【解决方案1】:

    我刚刚在路由定义的不一致接口中找到了解决方案:

    如果您为控制器提供以下架构,它就可以工作:

    'controller' => 'User\Controller\Profile'
    

    如果能像http路由一样定义就好了:

    'defaults' => array(
        '__NAMESPACE__' => 'User\Controller',
        'controller' => 'Profile',
        'action' => 'setpassword',
    ),
    

    刚刚为此打开了一个问题:http://framework.zend.com/issues/browse/ZF2-515

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-09
      • 2014-05-02
      • 2015-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多