2017 © Pedro Peláez
 

library dependency-resolver

A simple component to resolve dependencies

image

paritybit/dependency-resolver

A simple component to resolve dependencies

  • Friday, May 13, 2016
  • by mkpeacock
  • Repository
  • 1 Watchers
  • 2 Stars
  • 30 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Simple dependency resolver

Coverage Status Build Status, (*1)

A simple framework for resolving dependencies in code and managing a mapping of configurations to determine how specific dependencies should be resolved., (*2)

This isn't optimal and there are likely better implementations out there, but I needed something very quickly for a few specific, temporary, use cases. So it may not be very useful in general., (*3)

Installation

With composer, (*4)

php composer.phar require paritybit/dependency-resolver

Usage

There is an example Resolution implementation CallableResolution. A Resolution is the encapsulation of a particular dependency. If one of your dependencies is an object, then you would tell the Resolution how to create or get this object in order for it to be provided when something is dependent on it. In most cases you would want to create your own Resolution implementation. My own use case was to get an object from a container until the container could be refactored away., (*5)

Create a map of your dependencies, (*6)

use ParityBit\DependencyResolver\DependencyMap;
use ParityBit\DependencyResolver\DependencyConfigurations\CallableResolution;
use My\Applications\Dependency;

$map = new DependencyMap();
$map->registerResolution(
    Dependency::class,
    new CallableResolution(function () {
        return new Dependency();
    })
);

Instantiate the appropriate resolver, (*7)

$resolver = new ParityBit\DependencyResolver\ConstructorArgumentResolver($map);

Resolve your dependencies, (*8)

use Class\With\Dependencies\In\Constructor as ToResolve;

// find dependencies, instantiate dependent object and inject dependencies
$resolved = $resolver->resolve(ToResolve::class);

The Versions

13/05 2016

dev-master

9999999-dev

A simple component to resolve dependencies

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

dependencies dependency resolver

13/05 2016

v1.0.0

1.0.0.0

A simple component to resolve dependencies

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

dependencies dependency resolver