From 141074a24e7aa198d4b6095572a78226f89a5d33 Mon Sep 17 00:00:00 2001 From: Adrian Zmenda Date: Sun, 18 Mar 2018 17:27:11 +0100 Subject: [PATCH] Tweak README to include new configuration details for Symfony 4, tweak variable name --- README.md | 62 +++++++++++++---------- src/ServiceContainer/SymfonyExtension.php | 4 +- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 631faed..18b8f35 100644 --- a/README.md +++ b/README.md @@ -28,30 +28,40 @@ ensures that application behaviour will not be affected by stateful services. FriendsOfBehat\SymfonyExtension: ~ ``` - **Symfony 3 configuration** - - ``` - FriendsOfBehat\SymfonyExtension: - kernel: - bootstrap: 'var/bootstrap.php.cache' - path: app/AppKernel.php - class: 'AppKernel' - env: test - debug: true - ``` - - **Symfony 4 configuration** - - ``` - FriendsOfBehat\SymfonyExtension: - # .env.dist file will be used if .env file does not exist - env_file: .env - kernel: - class: 'MyTrip\Kernel' - path: src/Kernel.php - debug: true - ``` - - Symfony 4 does not have bootstrap file anymore and the environment is configured in the .env file. - 3. Good luck & have fun! + + +## Configuration + +SymfonyExtension provides kind of autoconfiguration feature. +When none explicit configuration is set, we will set for You sane default that will get you running fast. + +**Default Symfony 3 configuration** + +``` +FriendsOfBehat\SymfonyExtension: + kernel: + bootstrap: 'app/autoload.php' # you may want to use var/bootstrap.php.cache instead + path: app/AppKernel.php + class: 'AppKernel' + env: test + debug: true +``` + +**Default Symfony 4 configuration** + +``` +FriendsOfBehat\SymfonyExtension: + # .env.dist file will be used if .env file does not exist + env_file: .env + kernel: + bootstrap: ~ + path: src/Kernel.php + class: 'App\Kernel' + env: test # When explicitly set, will override APP_ENV loaded from env_file file + debug: true # When explicitly set, will override APP_DEBUG loaded from env_file file +``` + +Symfony 4 is detected, based on the existence of `src/Kernel.php` file, so if you did not migrate to new Symfony structure yet; you need to set those values yourself. + +Of course, you can always change each of those settings. diff --git a/src/ServiceContainer/SymfonyExtension.php b/src/ServiceContainer/SymfonyExtension.php index bceb678..87ee0f7 100644 --- a/src/ServiceContainer/SymfonyExtension.php +++ b/src/ServiceContainer/SymfonyExtension.php @@ -169,8 +169,8 @@ final class SymfonyExtension implements Extension $defaults = self::SYMFONY_DEFAULTS; - $symfonyFlexKernelPath = sprintf('%s/%s', $container->getParameter('paths.base'), self::SYMFONY_4_DEFAULTS['kernel']['path']); - if (file_exists($symfonyFlexKernelPath)) { + $symfony4KernelPath = sprintf('%s/%s', $container->getParameter('paths.base'), self::SYMFONY_4_DEFAULTS['kernel']['path']); + if (file_exists($symfony4KernelPath)) { $defaults = self::SYMFONY_4_DEFAULTS; }