Skip to content

Commit dacf020

Browse files
authored
Merge pull request #4 from alexpts/change-watcher-to-symfony-config
Refactoring cache watcher
2 parents 0968bb7 + 082475d commit dacf020

28 files changed

+467
-974
lines changed

Diff for: .editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ root = true
22

33
[*.php]
44
indent_style = space
5-
indent_size = 2
5+
indent_size = 4
66
charset = utf-8
77
trim_trailing_whitespace = true
88

Diff for: README.md

+13-15
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![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)
44
[![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)
55

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)
77

88
### Install
99
`composer require alexpts/symfony-di-loader`
@@ -14,26 +14,24 @@ Simple loader for symfony [DependencyInjection component]( https://symfony.com/d
1414
<?php
1515
use PTS\SymfonyDiLoader\LoaderContainer;
1616

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;
1924

2025
$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);
3127
```
3228

3329
Custom container extension:
3430
```php
31+
use PTS\SymfonyDiLoader\LoaderContainer;
32+
3533
$loader = new LoaderContainer;
36-
$loader->addExtension($someContainerExtension);
37-
$loader->addExtension($someContainerExtension2);
34+
$builder = $loader->getBuilder();
35+
$builder->addExtension($someContainerExtension);
3836
$container = $loader->getContainer($configs, $fileCache);
3937
```

Diff for: composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"require": {
2222
"php": "^8.1",
2323
"ext-json": "*",
24-
"symfony/dependency-injection": "^6.0",
25-
"symfony/yaml": "^6.0",
26-
"symfony/config": "^6.0"
24+
"symfony/dependency-injection": "^6.1",
25+
"symfony/yaml": "^6.1",
26+
"symfony/config": "^6.1"
2727
},
2828
"autoload": {
2929
"psr-4": {

0 commit comments

Comments
 (0)