interophp/injector

Inject dependencies into constructors and methods

v1.0.0 2016-07-10 13:28 UTC

This package is auto-updated.

Last update: 2024-03-25 20:59:59 UTC


README

Simple constructor and method argument injector.

You can pass a context to the injector to resolve parameters into injectable values.

Supported contexts:

  • ArrayContext: Resolves by a simple associative array's key/value
  • RequestContext: Uses a PSR7 ServerRequest to resolve values from request attributes
  • InteropContainerContext: Add support for DI containers implementing Interop\Container\ContainerInterface
  • PsrContainerContext: Add support for DI containers implementing Psr\Container\ContainerInterface
  • MultiContext: Pass an array of one or more of the above contexts to resolve from multiple contexts.

It's simple to add your own contexts by implementing InteroPhp\Injector\Context\ContextInterface

Examples and usage

Please check the included example/ directory for usage examples.

License

MIT (see LICENSE.md)

Brought to you by the LinkORB Engineering team

687474703a2f2f7777772e6c696e6b6f72622e636f6d2f642f6d6574612f74696572312f696d616765732f6c696e6b6f7262656e67696e656572696e672d6c6f676f2e706e67
Check out our other projects at linkorb.com/engineering.

Btw, we're hiring!