Skip to content

Reference implementations of the Ioc-Interop interfaces.

License

Notifications You must be signed in to change notification settings

ioc-interop/impl

Repository files navigation

ioc-interop/impl

PDS Skeleton PDS Composer Script Names

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;
    });

About

Reference implementations of the Ioc-Interop interfaces.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages