ioc-interop / impl
Reference implementations of Ioc-Interop.
1.x-dev
2026-01-31 15:07 UTC
Requires
- php: ^8.4
- env-interop/interface: 1.x@dev
- ioc-interop/interface: 1.x@dev
Requires (Dev)
- pds/composer-script-names: ^1.0
- pds/skeleton: ^1.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2026-03-01 00:48:53 UTC
README
This package offers a reference implementation all the Ioc-Interop interface to present a typical "open" autowired container.
Installation
$ composer require ioc-interop/impl
Getting Started
use IocInterop\Impl\Container; use IocInterop\Interface\IocContainer; $ioc = new Container();
Getting Services
$foo = $ioc->getService(Foo::class);
Setting Service Instances
$ioc->setService(Foo::class, new Foo());
Setting Service Aliases
$ioc->setAlias('foo.foo', Foo::class); $foo = $ioc->getService('foo.foo');
Defining Services
Service Factory
$ioc->getDefinition(Foo::class) ->setFactory(fn (IocContainer $ioc) : Foo => return new Foo());
Service Extenders
$ioc->getDefinition(Foo::class) ->addExtender(function (IocContainer $ioc, Foo $foo) : Foo { $foo->bar = 'baz'; return $foo; });