|
15 | 15 | declare(strict_types=1); |
16 | 16 |
|
17 | 17 | use Foundation\Application; |
| 18 | +use Foundation\Bridge\Symfony\Component\DependencyInjection\Configurator\YamlConfigurator; |
18 | 19 | use Symfony\Component\Config\FileLocator; |
19 | | -use Symfony\Component\DependencyInjection\ContainerBuilder; |
20 | | -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
21 | | -use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag; |
22 | | -use Symfony\Component\Dotenv\Dotenv; |
23 | | -use Symfony\Component\Yaml\Yaml; |
24 | 20 |
|
25 | 21 | require_once __DIR__ . '/../vendor/autoload.php'; |
26 | 22 |
|
27 | | -$envFilePath = __DIR__ . '/../.env'; |
| 23 | +$parameterFilePath = __DIR__ . '/../config/parameters.yml'; |
28 | 24 |
|
29 | | -// will populate env variables from env-type files (only if they're not already set). |
30 | | -if (file_exists($envFilePath)) { |
31 | | - (new Dotenv())->loadEnv($envFilePath); |
32 | | -} |
33 | | - |
34 | | -$configFilePath = __DIR__ . '/../config/parameters.yml'; |
35 | | - |
36 | | -if (!file_exists($configFilePath)) { |
| 25 | +if (!file_exists($parameterFilePath)) { |
37 | 26 | throw new RuntimeException("File 'parameters.yml' is missing. Please, put it into the 'config' directory."); |
38 | 27 | } |
39 | 28 |
|
40 | | -$config = Yaml::parseFile($configFilePath); |
41 | | -$parameterBag = new EnvPlaceholderParameterBag($config['parameters']); |
42 | | - |
43 | | -$container = new ContainerBuilder($parameterBag); |
44 | | - |
45 | | -// loading service definitions. |
46 | | -$definitionLoader = new YamlFileLoader($container, new FileLocator()); |
47 | | -$definitionFilePaths = [ |
48 | | - __DIR__ . '/../config/services/request_handlers.yml', |
49 | | - __DIR__ . '/../config/services/loggers.yml', |
50 | | - __DIR__ . '/../config/services/shutdown.yml', |
51 | | - __DIR__ . '/../config/services/async/streams.yml', |
52 | | - __DIR__ . '/../config/services/async/server.yml', |
53 | | - __DIR__ . '/../config/services/async/event_loop.yml', |
54 | | - __DIR__ . '/../config/services.yml', |
55 | | -]; |
56 | | - |
57 | | -foreach ($definitionFilePaths as $definitionFilePath) { |
58 | | - $definitionLoader->load($definitionFilePath); |
59 | | -} |
60 | | - |
| 29 | +$containerConfigurator = new YamlConfigurator(new FileLocator()); |
| 30 | +$containerConfigurator->setEnvironmentFilePath(__DIR__ . '/../.env'); |
| 31 | +$containerConfigurator->setParameterFilePath($parameterFilePath); |
| 32 | +$containerConfigurator->setDefinitionFilePaths( |
| 33 | + [ |
| 34 | + __DIR__ . '/../config/services.yml', |
| 35 | + __DIR__ . '/../config/services/loggers.yml', |
| 36 | + __DIR__ . '/../config/services/async/event_loop.yml', |
| 37 | + __DIR__ . '/../config/services/async/server.yml', |
| 38 | + __DIR__ . '/../config/services/async/streams.yml', |
| 39 | + __DIR__ . '/../config/services/shutdown.yml', |
| 40 | + __DIR__ . '/../config/services/request/uri_matcher.yml', |
| 41 | + __DIR__ . '/../config/services/request/handler.yml', |
| 42 | + ] |
| 43 | +); |
| 44 | +$containerConfigurator->setDefinitionDefaultsFilePath(__DIR__ . '/../config/services.yml'); |
| 45 | + |
| 46 | +$container = $containerConfigurator->getContainerBuilder(); |
61 | 47 | // we are starting an async web server with some concurrent code |
62 | 48 | // so we don't need any container caching logic for this case. |
63 | 49 | $container->compile(true); |
|
0 commit comments