路徑:/module/Application/config/module.config.php
內容如下:
~~~
return array(
'router' => array(
'routes' => array(
'application' => array(
'type' => 'segment',
'options' => array(
'route' => '/[application][:controller][/:action]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z0-9_-]*',
),
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index'
),
),
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController'
),
),
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
'application' => __DIR__ . '/../view'
),
),
'service_manager' => array(
'factories' => array(
'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
),
),
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'navigation' => array(
'default' => array(
array(
'label' => 'Home',
'route' => 'applicaton’
),
array(
'label' => 'Application',
'route' => 'application’,
'pages' => array(
array(
'label' => 'List',
'route' => 'application’,
'action' => 'list',
),
),
),
),
),
);
~~~
先對以上配置進行歸類:
~~~
array(// 總配置
‘router’ =>array(),// 路由
‘controllers’ =>array(),// 控制器
‘view_manager’ =>array(),// 視圖管理器
‘service_manager’ =>array(),// 服務器管理器
‘translator’ =>array(),// 譯碼器或翻譯器
‘navigation’ =>array(),// 頁面導航
);
~~~
下面對 router、controllers、view_manager、service_manager、translator 、navigation進行逐個解釋。
- 序言
- 第1章 Zend Framework2 簡介
- 1.1 Zend Framework2 簡介
- 1.2 下載安裝
- 1.3 搭建開發環境
- 第2章 創建ZF2項目
- 2.1 新建一個項目
- 2.2 配置網站
- 2.3 偽靜態 .htaccess文件
- 2.4 添加啟動/入口文件
- 2.5 添加全局配置文件
- 2.6 添加自動加載文件 init_autoloader.php
- 2.7 IndexController 控制器
- 第3章 創建模塊文件
- 3.1 Module 文件
- 3.2 module.config 文件
- 3.2.1 router 路由配置
- 3.2.2 controllers控制器配置
- 3.2.3 view_manager 視圖管理器
- 3.2.4 service_manager 服務管理器
- 3.2.5 translator 翻譯器
- 3.2.6 navigation 導航條
- 第4章 創建控制器
- 4.1 控制器簡介
- 4.2 新建控制器
- 4.3 添加控制器的Action
- 第5章 創建視圖模板
- 5.1 創建模板
- 5.2 模板配置
- 5.3 編寫布局和錯誤異常模板
- 5.4 編寫Action 對應的模板文件
- 5.5 訪問 IndexAction
- 第6章 創建模型
- 6.1 ORM 對象映射法
- 6.2 使用分頁導航
- 6.3 自定模型
- 6.4 章節總結
- 第7章 實例應用
- 7.1 建立Album 模塊
- 7.2 添加模塊文件
- 7.3 添加模塊配置文件
- 7.4 創建數據表 album
- 7.5 添加模型文件
- 7.6 添加表單 AlbumForm
- 7.7 添加控制器 AlbumController
- 7.8 添加模板文件
- 第8章 用戶認證
- 8.1 建立數據表
- 8.2 新建認證類
- 8.3 引用認證類
- 第9章 結束語