2017 © Pedro Peláez
 

library auryn-container-interop

PSR-11 Container compatibility for Auryn

image

elazar/auryn-container-interop

PSR-11 Container compatibility for Auryn

  • Sunday, July 1, 2018
  • by elazar
  • Repository
  • 0 Watchers
  • 2 Stars
  • 105 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

auryn-container-interop

Build Status, (*1)

PSR-11 compatibility for Auryn, (*2)

License

This library is licensed under the MIT License., (*3)

Installation

Use composer., (*4)

composer require elazar/auryn-container-interop

Usage

use Elazar\Auryn\Container;
use Acme\SomeDependency;

$container = new Container;

if ($container->has(SomeDependency::class)) {
    // ...
}

$instance = $container->get(SomeDependency::class);

// All public methods of Auryn\Injector are available
$instance = $container->make(SomeDependency::class);

Be sure you are familiar with how Auryn works. As recommended by its author, avoid using it as a service locator., (*5)

Implementation

While I agree with a lot of the discussion in this issue regarding why new projects can use Auryn directly without a PSR-11 implementation, I do think that such an implementation can be useful for integrating Auryn with third-party libraries that use PSR-11, such as zend-expressive., (*6)

The implementation in this repository takes a small amount of liberty with this passage from Section 1.1.2 of the PSR-11 specification:, (*7)

has ... MUST return true if an entry identifier is known to the container, (*8)

Auryn uses fully qualified names for classes and interfaces to identify dependencies where most container implementations use user-designated names. As such, it's possible for Auryn to instantiate a class even if it contains no definitions for that class (e.g. if the class has no required constructor parameters or if those parameters are themselves instantiable classes)., (*9)

Because of this, ContainerInterface->has() in this PSR-11 implementation will return true if either the underlying Auryn\Injector instance has definitions for a requested class or interface or if a requested class is defined and considered instantiable (i.e. is not abstract and has a public implementation of __construct()). While some may view this as technically incorrect, it seems consistent to me with the overall spirit and intentions of the PSR-11 standard., (*10)

Development

To run the PHPUnit test suite:, (*11)

composer run-script test

The Versions

01/07 2018

dev-master

9999999-dev

PSR-11 Container compatibility for Auryn

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection psr-11 container-interop auryn

01/07 2018

3.0.0

3.0.0.0

PSR-11 Container compatibility for Auryn

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection psr-11 auryn

01/07 2018

dev-psr-11

dev-psr-11

PSR-11 Container compatibility for Auryn

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection psr-11 auryn

23/03 2018

2.1.0

2.1.0.0

container-interop compatibility for Auryn

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection container-interop auryn

02/07 2016

2.0.0

2.0.0.0

container-interop compatibility for Auryn

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection container-interop auryn

25/06 2016

1.0.0

1.0.0.0

container-interop compatibility for Auryn

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection container-interop auryn