Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ZendFramework自动路由don';行不通_Php_Zend Framework - Fatal编程技术网

Php ZendFramework自动路由don';行不通

Php ZendFramework自动路由don';行不通,php,zend-framework,Php,Zend Framework,我已经用类TestController创建了一个TestController.php有一个方法indexAction,但是我不能使用这个路由执行它,如果我写/application/index/test或/application/index/index-这一切都没问题,但是如果我更改控制器来测试它不起作用,我的意思是/application/test/test或/application/test/index不要忘记将新控制器添加到应用程序的module.config.php中的controlle

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

不要忘记将新控制器添加到应用程序的module.config.php中的controllers['invokables']config部分:

// 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(
                            ),
                        ),
                    ),
                ),
            ),
'controllers' => array(
        'invokables' => array(
            'Application\Controller\Index' => 'Application\Controller\IndexController',
            'Application\Controller\Test' => 'Application\Controller\TestController',
        ),
    ),