3
3
[ ![ phpunit] ( https://github.com/alexpts/php-symfony-di-loader/actions/workflows/phpunit.yml/badge.svg?branch=master )] ( https://github.com/alexpts/php-symfony-di-loader/actions/workflows/phpunit.yml )
4
4
[ ![ codecov] ( https://codecov.io/gh/alexpts/php-symfony-di-loader/branch/master/graph/badge.svg?token=14L6IJA5UE )] ( https://codecov.io/gh/alexpts/php-symfony-di-loader )
5
5
6
- Simple loader for symfony [ DependencyInjection component] ( https://symfony.com/doc/current/components/dependency_injection.html )
6
+ Simple loader for symfony container [ DependencyInjection component] ( https://symfony.com/doc/current/components/dependency_injection.html )
7
7
8
8
### Install
9
9
` composer require alexpts/symfony-di-loader `
@@ -14,26 +14,24 @@ Simple loader for symfony [DependencyInjection component]( https://symfony.com/d
14
14
<?php
15
15
use PTS\SymfonyDiLoader\LoaderContainer;
16
16
17
- $configs = ['./container.yml', './container.xml', './container.php'];
18
- $fileCache = __DIR__ . '/var/container.cache.php';
17
+ $configs = [
18
+ __DIR__ . './container.yml',
19
+ __DIR__ . './container.xml',
20
+ __DIR__ . './container.php'
21
+ ];
22
+ $fileCache = __DIR__ . '/var/di.php';
23
+ $isDebug = true;
19
24
20
25
$loader = new LoaderContainer;
21
- $container = $loader->getContainer($configs, $fileCache);
22
- ```
23
-
24
- Loader has autodetect config changes and watch services from configs and auto rebuild container.
25
- You can disable all watch for production:
26
- ``` php
27
- $loader = new LoaderContainer;
28
- $loader->setCheckExpired(false); // watch configs disable
29
- $loader->getWatcher()->setIsWatchReflection(false); // watch service class disable
30
- $container = $loader->getContainer($configs, $fileCache);
26
+ $container = $loader->getContainer($configs, $fileCache, $isDebug);
31
27
```
32
28
33
29
Custom container extension:
34
30
``` php
31
+ use PTS\SymfonyDiLoader\LoaderContainer;
32
+
35
33
$loader = new LoaderContainer;
36
- $loader->addExtension($someContainerExtension );
37
- $loader ->addExtension($someContainerExtension2 );
34
+ $builder = $ loader->getBuilder( );
35
+ $builder ->addExtension($someContainerExtension );
38
36
$container = $loader->getContainer($configs, $fileCache);
39
37
```
0 commit comments