visma / php-di-bootstrapper
PHP-DI bootstrapper helpers
0.1.0
2020-01-30 12:38 UTC
Requires
- php: ^7.4
- php-di/php-di: ^6
- webmozart/assert: ^1.6
Requires (Dev)
- phpunit/phpunit: ^8.5
- squizlabs/php_codesniffer: ^3.5
- vimeo/psalm: ^3.8
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();