2017 © Pedro Peláez
 

library php-container

Simple Dependency Injection Container

image

frostealth/php-container

Simple Dependency Injection Container

  • Friday, November 13, 2015
  • by frostealth
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

PHP Container

Simple Dependency Injection Container., (*1)

Installation

Run the Composer command to install the latest stable version:, (*2)

composer require frostealth/php-container @stable

Usage

use frostealth\Container\Container;

$container = new Container();

// ...

// injecting simple values
$container->set('foo', 'bar'); // or $container->foo = 'bar';

// get its value
$value = $container->get('foo');  // or $value = $container->foo;

// ...

// resources 
$container->set('object', function ($container) {
    return new MyObject($container->foo);
});

// get a new instance
$object = $container->get('object');

// ...

// singleton resources
$container->singleton('log', function ($container) {
    return new MyLog($container->object);
});

// get log resource
$log = $container->get('log');

Dependency Injection

use Interop\Container\ContainerInterface;

class MyClass
{
    /**
     * @var ContainerInterface
     */
    protected $container;

    /**
     * @param ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }
}

License

The MIT License (MIT). See LICENSE.md for more information., (*3)

The Versions

13/11 2015

dev-master

9999999-dev

Simple Dependency Injection Container

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection container di

09/11 2015

2.0.0

2.0.0.0

Simple Dependency Injection Container

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection container di

11/04 2015

1.0.2

1.0.2.0

PHP Container

  Sources   Download

MIT

The Requires

 

The Development Requires

container di

30/09 2014

1.0.1

1.0.1.0

PHP Container

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kudinov Ivan

container di

29/08 2014

1.0.0

1.0.0.0

PHP Resource Locator

  Sources   Download

The Requires

 

by Kudinov Ivan