2017 © Pedro Peláez
 

library ldc-zf1-di-leaguecontainer

Basic controller dependency injection in ZF1 with League\Container

image

adamlundrigan/ldc-zf1-di-leaguecontainer

Basic controller dependency injection in ZF1 with League\Container

  • Thursday, July 2, 2015
  • by adamlundrigan
  • Repository
  • 1 Watchers
  • 2 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

LdcZf1DiLeagueContainer

Latest Stable Version License Build Status Code Coverage Scrutinizer Code Quality, (*1)

What?

It's a simple glue layer which injects services registered in a League\Container into a ZF1 controller., (*2)

Heavily based on @weierophinney's now-many-moons-ago blog post "A Simple Resource Injector for ZF Action Controllers"., (*3)

How?

  1. Install the Composer package:, (*4)

    composer require adamlundrigan/ldc-zf1-di-league-container:1.*@stable
    
  2. Register the helper in your ZF1 application bootstrap:, (*5)

    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:, (*6)

    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., (*7)

  4. Profit! The injector will create a public property on the controller instance for each named service., (*8)

The Versions

02/07 2015

dev-master

9999999-dev

Basic controller dependency injection in ZF1 with League\Container

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

02/07 2015

1.1.0

1.1.0.0

Basic controller dependency injection in ZF1 with League\Container

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

30/06 2015

1.0.0

1.0.0.0

Basic controller dependency injection in ZF1 with League\Container

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires