我们通常会把Service Manager配置在两个地方
1.module.config.php
2.Module.php
不同的service manager 类型有不同的配置方法
Application services
Manager | Application services |
Manager class | Zend\ServiceManager\ServiceManager |
Config key | service_manager |
Module method | getServiceConfig() |
Module interface | ServiceProviderInterface |
moduel.config.php
|
Moduel.php
|
Controllers
Manager | Controllers |
Manager class | Zend\Mvc\Controller\ControllerManager |
Config key | controllers |
Module method | getControllerConfig() |
Module interface | ControllerProviderInterface |
Service name | ControllerLoader |
module.config.php
|
Module.php
|
Controller plugins
Manager | Controller plugins |
Manager class | Zend\Mvc\Controller\PluginManager |
Config key | controller_plugins |
Module method | getControllerPluginConfig() |
Module interface | ControllerPluginProviderInterface |
Service name | ControllerPluginManager |
module.config.php
|
Module.php
|
View helpers
Manager | View helpers |
Manager class | Zend\View\HelperPluginManager |
Config key | view_helpers |
Module method | getViewHelperConfig() |
Module interface | ViewHelperProviderInterface |
Service name | ViewHelperManager |
module.config.php
|
Module.php
// Application/Module.php
class
Module{
public
function
getViewHelperConfig()
{
return
array
(
‘factories‘
=>
array
(
‘ApplicationHelper‘
=>
function
( $helperPluginManager
) {
// ....
}
),
// 也可以添加其他服务
);
}
// 省略其他Module.php代码
}