Skip to content

DannyMeyer/laminas-di-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

laminas-di-helper

Laminas based helper for dependency injection

Setup:

\DannyMeyer\Di\Container::addConfiguration(
    new \Laminas\ConfigAggregator\ConfigAggregator(
        [
            MyConfigProvider::class
        ]
    )
);

Example for ConfigProvider:

class MyConfigProvider {

    /**
     * @return array
     */
    public function __invoke(): array
    {
        return [
            \DannyMeyer\Di\Container::CONFIG_DEPENDENCIES => [
                \DannyMeyer\Di\Container::CONFIG_FACTORIES => [
                    MyClass::class => \Laminas\ServiceManager\Factory\InvokableFactory::class,
                ],
            ]
        ];
    }
}

Usage:

$container = \DannyMeyer\Di\Container::getInstance();
$container->get(MyClass::class);