adamlundrigan/ldc-zf1-di-leaguecontainer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Stable Version License Build Status Code Coverage Scrutinizer Code Quality

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?

  1. Install the Composer package:

    composer require adamlundrigan/ldc-zf1-di-league-container:1.*@stable
    
  2. 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()
        );
    }
    
  3. 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 $dependencies the injector will use that as the controller property to inject into.

  4. Profit! The injector will create a public property on the controller instance for each named service.

统计信息

  • 总下载量: 32
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-06-30