visma/php-di-bootstrapper

PHP-DI bootstrapper helpers

0.1.0 2020-01-30 12:38 UTC

This package is auto-updated.

Last update: 2024-11-27 23:43:01 UTC


README

Usage

Make an empty container (not very useful):

$bootstrap = new \Visma\PhpDiBootstrapper\Bootstrap();

$container = $bootstrap->create();

Usage with files

Load all files in the provided directory recusively as definitions, sorted by name

$bootstrap = new \Visma\PhpDiBootstrapper\Bootstrap();
$bootstrap->addDefinitionsFromDirectory(__DIR__ . '/src/definitions/');

$container = $bootstrap->create();

Usage with files and container compilation

Load all files in the provided directory recusively as definitions, sorted by name, only reading the files if the container is not already compiled

$bootstrap = new \Visma\PhpDiBootstrapper\Bootstrap();
$bootstrap->enableCompilation(__DIR__ . '/generated/container/');
$bootstrap->addDefinitionsFromDirectory(__DIR__ . '/src/definitions/');

$container = $bootstrap->create();