adamlundrigan/ldc-zf1-di-leaguecontainer
最新稳定版本:1.1.0
Composer 安装命令:
composer require adamlundrigan/ldc-zf1-di-leaguecontainer
包简介
Basic controller dependency injection in ZF1 with League\Container
README 文档
README
What?
It's a simple glue layer which injects services registered in a League\Container into a ZF1 controller.
Heavily based on @weierophinney's now-many-moons-ago blog post "A Simple Resource Injector for ZF Action Controllers".
How?
-
Install the Composer package:
composer require adamlundrigan/ldc-zf1-di-league-container:1.*@stable -
Register the helper in your ZF1 application bootstrap:
protected function _initContainer() { $container = new League\Container\Container(); // Fill your container return $container; } protected function _initContainerResourceInjector() { $this->bootstrap('container'); Zend_Controller_Action_HelperBroker::addHelper( new \LdcZf1DiLeagueContainer\DependencyInjector() ); } -
In each controller, define a list of dependencies to inject:
class FooController extends Zend_Controller_Action { public $dependencies = array( 'db', 'layout', 'navigation', ); }If you use a non-numeric key for any value of
$dependenciesthe injector will use that as the controller property to inject into. -
Profit! The injector will create a public property on the controller instance for each named service.
统计信息
- 总下载量: 32
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-06-30