2017 © Pedro Peláez
 

library container

Contain and inject dependencies

image

seeren/container

Contain and inject dependencies

  • Sunday, April 1, 2018
  • by seeren
  • Repository
  • 0 Watchers
  • 0 Stars
  • 195 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Seeren\Container

Build Require Coverage Download Codacy Badge Version, (*1)

Autowire and configure dependencies, (*2)


Installation

Seeren\Container is a PSR-11 container interfaces implementation, (*3)

composer require seeren/container

Seeren\Container\Container

The container create, build, store and share instances, (*4)

use Seeren\Container\Container;

$container = new Container();

$foo = $container->get('Dummy\Foo');

Autowiring

Dependencies are resolved using type declaration, (*5)

namespace Dummy;

class Foo
{
    public function __construct(Bar $bar){}
}

class Bar 
{
    public function __construct(Baz $baz){}
}

class Baz {}

Interfaces

namespace Dummy;

class Foo {
    public function __construct(BarInterface $bar){}
}

Interfaces are resolved using configuration file by default in /config/services.json, (*6)

{
  "parameters": {},
  "services": {
    "Dummy\\Foo": {
      "Dummy\\BarInterface": "Dummy\\Bar"
    }
  }
}

Include path can be specified at construction, (*7)

project/
└─ config/
   └─ services.json

Parameters

Parameters and primitives are resolved using configuration file, (*8)

namespace Dummy;

class Foo
{
    public function __construct(string $bar){}
}
{
  "parameters": {
    "message": "Hello"
  },
  "services": {
    "Dummy\\Foo": {
      "bar": ":message"
    }
  }
}

Methods

Methods can use autowiring, (*9)

namespace Dummy;

class Foo
{

    public function __construct(BarInterface $bar){}

    public function action(int $id, Baz $baz)
    {
        return 'Hello';
    }

}
use Seeren\Container\Container;

$container = new Container();

$message = $container->call('Dummy\Foo', 'action', [7]);

echo $message; // Hello

License

This project is licensed under the MIT License, (*10)

The Versions

01/04 2018

dev-master

9999999-dev

Contain and inject dependencies

  Sources   Download

MIT

The Requires

 

The Development Requires

container resolver dependency-injection psr-11

01/04 2018

v1.4.2

1.4.2.0

Contain and inject dependencies

  Sources   Download

MIT

The Requires

 

The Development Requires

container dependency-injection psr-11

01/04 2018

v1.4.1

1.4.1.0

Contain and inject dependencies

  Sources   Download

MIT

The Requires

 

The Development Requires

container dependency-injection psr-11

17/03 2018

v1.4

1.4.0.0

Contain and inject dependencies

  Sources   Download

MIT

The Requires

 

The Development Requires

container dependency-injection psr-11

13/06 2017

v1.3.1

1.3.1.0

Resolve and cache dependencies

  Sources   Download

MIT

The Requires

 

The Development Requires

container resolver dependency-injection psr-11

15/04 2017

v1.2.1

1.2.1.0

Psr 11 implementation, resolve and cache dependencies

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 cache psr-6

26/02 2017

v1.2

1.2.0.0

Psr 11 implementation, resolve and cache dependencies

  Sources   Download

MIT

The Requires

 

02/11 2016

v1.1.3

1.1.3.0

Psr 11 implementation, resolve and cache dependencies

  Sources   Download

MIT

The Requires

 

20/10 2016

v1.1.1

1.1.1.0

Psr 11 implementation, resolve and cache dependencies

  Sources   Download

MIT

The Requires

 

14/10 2016

v1.0.1

1.0.1.0

Psr 11 implementation, resolve and cache dependencies

  Sources   Download

MIT

The Requires