Skip to content

Commit

Permalink
feat: add a fluent interface usage example in the framework config
Browse files Browse the repository at this point in the history
  • Loading branch information
COil committed Dec 29, 2024
1 parent b719537 commit 1cbc6b7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions config/packages/framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ parameters:
# https://github.com/phpstan/phpstan-symfony#configuration
symfony:
containerXmlPath: var/cache/dev/App_KernelDevDebugContainer.xml
# @see config/packages/security.php
scanDirectories:
- var/cache/dev/Symfony/Config
# https://phpstan.org/user-guide/ignoring-errors
ignoreErrors:
#- '#my_ignore_error_regexp_pattern#'

0 comments on commit 1cbc6b7

Please sign in to comment.