加载中...

7.3 添加模块配置文件


模块配置文件主要对路由、视图等进行配置,此处配置关系到整个模块的访问方式及其他使用方式。

添加文件:/module/Album/config/module.config.php,添加内容如下:

  1. return array(
  2. 'router' => array(
  3. 'routes' => array(
  4. 'album' => array(
  5. 'type' => 'segment',
  6. 'options' => array(
  7. 'route' => '/album[/][:action][/:id]',
  8. 'constraints' => array(
  9. 'action' => '[a-zA-Z0-9_-]*',
  10. 'id'=>'[0-9]*'
  11. ),
  12. 'defaults' => array(
  13. 'controller' => 'Album\Controller\Album',
  14. 'action' => 'index'
  15. ),
  16. ),
  17. ),
  18. ),
  19. ),
  20. 'controllers' => array(
  21. 'invokables' => array(
  22. 'Album\Controller\Album' => 'Album\Controller\AlbumController'
  23. ),
  24. ),
  25. 'view_manager' => array(
  26. 'template_path_stack' => array(
  27. 'album' => __DIR__ . '/../view',
  28. ),
  29. ),
  30. );

代码解释:

'router' => array() 路径配置区块,可以包括有多条路由

'controllers' => array() 控制器配置区块,此处可以配置控制的使用情况

'view_manager' => array() 视图配置区块,此处配置视图存放路径;Album 模块没有再单独使用layout配置,与之前 的Application共用同一们layout布局


还没有评论.