当项目中有多个控制器时invoables和router如何配置:

jack张 发布于 2013/11/14 00:12
阅读 65
收藏 0

@Jacky.Wang 你好,想跟你请教个问题:

官方给的实例中只有一个控制器:

当项目中有多个控制器时我是否是需要类似这样的配置:

 'controllers' => array(
04         'invokables' => array(
05             'Album\Controller\Album' => 'Album\Controller\AlbumController',

               'Album\Controller\Dosomething' => 'Album\Controller\DosmothingController',

06         ),
07     ),
08  
09     // 那么是否是也需要设置Dosomething的路由如:
10     'router' => array(
11         'routes' => array(
12             'album' => array(
13                 'type'    => 'segment',
14                 'options' => array(
15                     'route'    => '/album[/:action][/:id]',
16                     'constraints' => array(
17                         'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
18                         'id'     => '[0-9]+',
19                     ),
20                     'defaults' => array(
21                         'controller' => 'Album\Controller\Album',
22                         'action'     => 'index',
23                     ),
24                 ),
25             ),

                    

         'dosmoething' => array(
13                 'type'    => 'segment',
14                 'options' => array(
15                     'route'    => '/album/dosomething[/][/:action][/:id]',
16                     'constraints' => array(
17                         'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
18                         'id'     => '[0-9]+',
19                     ),
20                     'defaults' => array(
21                         'controller' => 'Album\Controller\Dosomething',
22                         'action'     => 'index',
23                     ),
24                 ),
25             ),

26         ),
27     ),
28  
 

加载中
返回顶部
顶部