From 7f621d13967eddd40b75510cb0daf1d637aa9f85 Mon Sep 17 00:00:00 2001 From: COil Date: Sun, 29 Dec 2024 21:20:28 +0100 Subject: [PATCH] feat: add a fluent interface usage example in the framework config --- config/packages/framework.php | 7 +++++-- config/services.php | 6 ++++++ phpstan.neon | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/config/packages/framework.php b/config/packages/framework.php index 2d62a62..0b18c5b 100644 --- a/config/packages/framework.php +++ b/config/packages/framework.php @@ -3,11 +3,14 @@ declare(strict_types=1); use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use Symfony\Config\FrameworkConfig; // @see var/cache/dev/Symfony/Config/FrameworkConfig.php + +return static function (ContainerConfigurator $containerConfigurator, FrameworkConfig $frameworkConfig): void { + $frameworkConfig->secret('%env(APP_SECRET)%'); -return static function (ContainerConfigurator $containerConfigurator): void { // see https://symfony.com/doc/current/reference/configuration/framework.html $containerConfigurator->extension('framework', [ - 'secret' => '%env(APP_SECRET)%', + // 'secret' => '%env(APP_SECRET)%', // set at line 9 with the fluent interface. // 'csrf_protection' => true, 'http_method_override' => false, 'handle_all_throwables' => true, diff --git a/config/services.php b/config/services.php index bac5c14..a942b6e 100644 --- a/config/services.php +++ b/config/services.php @@ -9,6 +9,12 @@ // The PHP configuration files have been generated with symplify/config-transformer. // @see https://github.com/symplify/config-transformer +// In each PHP config file the "ContainerConfigurator" service is injected. +// If you want to use the fluent interface you can add the specific extension configurator +// Check out the full example in "config/packages/framework.php". +// This feature is only available for "root" services corresponding to the +// "var/cache/dev/Symfony/Config/*Config.php" configurators. + declare(strict_types=1); use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; diff --git a/phpstan.neon b/phpstan.neon index 3d132b1..585ccf9 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -20,6 +20,9 @@ parameters: # https://github.com/phpstan/phpstan-symfony#configuration symfony: containerXmlPath: var/cache/dev/App_KernelDevDebugContainer.xml + # @see config/packages/framework.php + scanDirectories: + - var/cache/dev/Symfony/Config # https://phpstan.org/user-guide/ignoring-errors ignoreErrors: #- '#my_ignore_error_regexp_pattern#'