Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 656 Bytes

File metadata and controls

33 lines (24 loc) · 656 Bytes

Container loader

I suggest you to create a ContainerLoader class like the following:

use Sensorario\Container\Container;

class ContainerLoader
{
    public static function load() : Sensorario\Container\Container
    {
        $container =  new Container();

        $container->loadServices([
            'service.name' => [
                'class' => 'Your\Own\Service',
            ]
        ]);

        return $container;
    }
}

This allow you to load the container just with ContainerLoader::load();.

Just adding these lines:

$this->container = ContainerLoader::load();

you'll reach all your services and components.