amphp / injector

A recursive dependency injector used to bootstrap and wire together S.O.L.I.D., object-oriented PHP applications.
MIT License
31 stars 7 forks source link

Add container adapter for PSR-11 support #10

Closed vlakarados closed 3 years ago

vlakarados commented 3 years ago

Fixes #7

Will update documentation if this get's positive feedback. Also tell me if we should add psr/container to suggested packages.

This is based on https://github.com/elazar/auryn-container-interop with the exception of composition over inheritance.

Why? Because this won't allow using the PSR-11-ready object in your application and you will still use the \Amp\Injector\Injector to set up the dependencies.

Usage:

$injector = new \Amp\Injector\Injector;

$containerConsumingObject->setContainer(new \Amp\Injector\ContainerAdapter($injector));
szepeviktor commented 3 years ago

You're commits are made with a non-GitHub (eco-fin) email address.

kelunik commented 3 years ago

@vlakarados Thank you for your PR. However, I went a different route and added support for arbitrary identifiers like in PSR-11 instead of using types as identifiers in the latest master branch. I'll therefore close this PR.