Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a fluent interface usage example in the framework config #148

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/framework.php
scanDirectories:
- var/cache/dev/Symfony/Config
# https://phpstan.org/user-guide/ignoring-errors
ignoreErrors:
#- '#my_ignore_error_regexp_pattern#'
Loading