首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ZendFramework autoRouting不工作

ZendFramework autoRouting不工作
EN

Stack Overflow用户
提问于 2013-03-29 15:29:35
回答 1查看 47关注 0票数 0
代码语言:javascript
复制
// The following is a route to simplify getting started creating
            // new controllers and actions without needing to create a new
            // module. Simply drop new controllers in, and you can access them
            // using the path /application/:controller/:action
            'application' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'    => '/application',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Application\Controller',
                        'controller'    => 'Index',
                        'action'        => 'index',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'default' => array(
                        'type'    => 'Segment',
                        'options' => array(
                            'route'    => '/[:controller[/:action]]',
                            'constraints' => array(
                                'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                            ),
                            'defaults' => array(
                            ),
                        ),
                    ),
                ),
            ),

我已经用类TestController创建了一个TestController.php有一个方法indexAction,但是我不能使用这个路由执行它,如果我写/application/index/test或者/application/index/index -一切都可以,但是如果我改变控制器来测试它不工作,我的意思是/application/ Test /test或者/application/test/index

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-29 15:40:49

不要忘记将新控制器添加到应用程序module.config.php中的控制器的可调用项的配置部分:

代码语言:javascript
复制
'controllers' => array(
        'invokables' => array(
            'Application\Controller\Index' => 'Application\Controller\IndexController',
            'Application\Controller\Test' => 'Application\Controller\TestController',
        ),
    ),
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15699172

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档