diff --git a/configuration.rst b/configuration.rst index 905e1e65d8a..c17a7aec413 100644 --- a/configuration.rst +++ b/configuration.rst @@ -106,10 +106,8 @@ configuration files, even if they use a different format: - + https://symfony.com/schema/dic/services/services-1.0.xsd" + > @@ -140,9 +138,9 @@ configuration files, even if they use a different format: $container->import('my_config_file.yaml', null, 'not_found'); // 'ignore_errors' set to true silently discards all errors (including invalid code and not found) $container->import('my_config_file.yaml', null, true); - }; - // ... + // ... + }; .. versionadded:: 4.4 @@ -191,12 +189,9 @@ reusable configuration value. By convention, parameters are defined under the - + https://symfony.com/schema/dic/services/services-1.0.xsd" + > @@ -249,10 +244,11 @@ reusable configuration value. By convention, parameters are defined under the // PHP constants as parameter values ->set('app.some_constant', GLOBAL_CONSTANT) - ->set('app.another_constant', BlogPost::MAX_ITEMS); - }; + ->set('app.another_constant', BlogPost::MAX_ITEMS) + ; - // ... + // ... + }; .. caution:: @@ -287,12 +283,12 @@ configuration file using a special syntax: wrap the parameter name in two ``%`` - + https://example.org/schema/dic/some-package + https://example.org/schema/dic/some-package/some-package-1.0.xsd" + > @@ -313,7 +309,6 @@ configuration file using a special syntax: wrap the parameter name in two ``%`` ]); }; - .. note:: If some parameter value includes the ``%`` character, you need to escape it @@ -333,18 +328,17 @@ configuration file using a special syntax: wrap the parameter name in two ``%`` + http://symfony.com/?foo=%%s&bar=%%d .. code-block:: php // config/services.php - namespace Symfony\Component\DependencyInjection\Loader\Configurator; - - return static function (ContainerConfigurator $container) { - $container->parameters() - ->set('url_pattern', 'http://symfony.com/?foo=%%s&bar=%%d'); - }; + $container->parameters() + // Parsed as 'https://symfony.com/?foo=%s&bar=%d' + ->set('url_pattern', 'http://symfony.com/?foo=%%s&bar=%%d') + ; .. include:: /components/dependency_injection/_imports-parameters-note.rst.inc @@ -508,13 +502,14 @@ This example shows how you could configure the database connection using an env xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/doctrine - https://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> - + https://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd" + > + .. code-block:: php @@ -528,6 +523,8 @@ This example shows how you could configure the database connection using an env // by convention the env var names are always uppercase 'url' => '%env(resolve:DATABASE_URL)%', ], + + // ... ]); }; @@ -805,6 +802,8 @@ doesn't work for parameters: app.contents_dir: '...' services: + # ... + App\Service\MessageGenerator: arguments: $contentsDir: '%app.contents_dir%' @@ -816,13 +815,15 @@ doesn't work for parameters: - + https://symfony.com/schema/dic/services/services-1.0.xsd" + > ... + + %app.contents_dir% @@ -838,11 +839,15 @@ doesn't work for parameters: return static function (ContainerConfigurator $container) { $container->parameters() - ->set('app.contents_dir', '...'); + ->set('app.contents_dir', '...') + ; $container->services() + // ... + ->get(MessageGenerator::class) - ->arg('$contentsDir', '%app.contents_dir%'); + ->arg('$contentsDir', '%app.contents_dir%') + ; }; If you inject the same parameters over and over again, use the @@ -873,8 +878,8 @@ whenever a service/controller defines a ``$projectDir`` argument, use this: - + https://symfony.com/schema/dic/services/services-1.0.xsd" + > - + https://symfony.com/schema/dic/services/services-1.0.xsd" + > + + Symfony\Component\HttpFoundation\Request::METHOD_HEAD + - - Symfony\Component\HttpFoundation\Request::METHOD_HEAD - + + - - - + + .. code-block:: php // config/packages/security.php - $container->setParameter('env(HEALTH_CHECK_METHOD)', 'Symfony\Component\HttpFoundation\Request::METHOD_HEAD'); - $container->loadFromExtension('security', [ - 'access_control' => [ - [ - 'path' => '^/health-check$', - 'methods' => '%env(const:HEALTH_CHECK_METHOD)%', + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + use Symfony\Component\HttpFoundation\Request; + + return static function (ContainerConfigurator $container) { + $container->parameters() + ->set('env(HEALTH_CHECK_METHOD)', Request::METHOD_HEAD) + ; + + $container->extension('security', [ + // ... + + 'access_control' => [ + [ + 'path' => '^/health-check$', + 'methods' => '%env(const:HEALTH_CHECK_METHOD)%', + ], ], - ], - ]); + ]); + }; ``env(base64:FOO)`` Decodes the content of ``FOO``, which is a base64 encoded string. @@ -215,8 +249,8 @@ Symfony provides the following env var processors: xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony - https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" + > ["10.0.0.1", "10.0.0.2"] @@ -227,10 +261,17 @@ Symfony provides the following env var processors: .. code-block:: php // config/packages/framework.php - $container->setParameter('env(TRUSTED_HOSTS)', '["10.0.0.1", "10.0.0.2"]'); - $container->loadFromExtension('framework', [ - 'trusted_hosts' => '%env(json:TRUSTED_HOSTS)%', - ]); + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->parameters() + ->set('env(TRUSTED_HOSTS)', '["10.0.0.1", "10.0.0.2"]') + ; + + $container->extension('framework', [ + 'trusted_hosts' => '%env(json:TRUSTED_HOSTS)%', + ]); + }; ``env(resolve:FOO)`` If the content of ``FOO`` includes container parameters (with the syntax @@ -252,29 +293,39 @@ Symfony provides the following env var processors: - - - - 10.0.0.1 - %env(HOST)% - http://%sentry_host%/project - - - - + https://symfony.com/schema/dic/services/services-1.0.xsd + https://sentry.io/schema/dic/sentry-symfony + https://sentry.io/schema/dic/sentry-symfony/sentry-1.0.xsd" + > + + 10.0.0.1 + %env(HOST)% + http://%sentry_host%/project + + + + .. code-block:: php // config/packages/sentry.php - $container->setParameter('env(HOST)', '10.0.0.1'); - $container->setParameter('sentry_host', '%env(HOST)%'); - $container->setParameter('env(SENTRY_DSN)', 'http://%sentry_host%/project'); - $container->loadFromExtension('sentry', [ - 'dsn' => '%env(resolve:SENTRY_DSN)%', - ]); + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->parameters() + ->set('env(HOST)', '10.0.0.1') + ->set('sentry_host', '%env(HOST)%') + ->set('env(SENTRY_DSN)', 'http://%sentry_host%/project') + ; + + $container->extension('sentry', [ + 'dsn' => '%env(resolve:SENTRY_DSN)%', + ]); + }; ``env(csv:FOO)`` Decodes the content of ``FOO``, which is a CSV-encoded string: @@ -299,8 +350,8 @@ Symfony provides the following env var processors: xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony - https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" + > 10.0.0.1,10.0.0.2 @@ -323,38 +374,49 @@ Symfony provides the following env var processors: .. code-block:: yaml - # config/packages/framework.yaml + # config/services.yaml parameters: env(AUTH_FILE): '../config/auth.json' - google: - auth: '%env(file:AUTH_FILE)%' + + services: + some_client: + $auth: '%env(file:AUTH_FILE)%' .. code-block:: xml - + - + https://symfony.com/schema/dic/services/services-1.0.xsd" + > ../config/auth.json - + + + %env(file:AUTH_FILE)% + + .. code-block:: php - // config/packages/framework.php - $container->setParameter('env(AUTH_FILE)', '../config/auth.json'); - $container->loadFromExtension('google', [ - 'auth' => '%env(file:AUTH_FILE)%', - ]); + // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->parameters() + ->set('env(AUTH_FILE)', '../config/auth.json') + ; + + $container->services() + ->set('some_client') + ->arg('$auth', '%env(file:AUTH_FILE)%') + ; + }; ``env(require:FOO)`` ``require()`` the PHP file whose path is the value of the ``FOO`` @@ -364,38 +426,49 @@ Symfony provides the following env var processors: .. code-block:: yaml - # config/packages/framework.yaml + # config/services.yaml parameters: env(PHP_FILE): '../config/.runtime-evaluated.php' - app: - auth: '%env(require:PHP_FILE)%' + + services: + some_client: + $auth: '%env(require:PHP_FILE)%' .. code-block:: xml - + - + https://symfony.com/schema/dic/services/services-1.0.xsd" + > ../config/.runtime-evaluated.php - + + + %env(require:PHP_FILE)% + + .. code-block:: php - // config/packages/framework.php - $container->setParameter('env(PHP_FILE)', '../config/.runtime-evaluated.php'); - $container->loadFromExtension('app', [ - 'auth' => '%env(require:PHP_FILE)%', - ]); + // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->parameters() + ->set('env(PHP_FILE)', '../config/.runtime-evaluated.php') + ; + + $container->services() + ->set('some_client') + ->arg('$auth', '%env(require:PHP_FILE)%') + ; + }; .. versionadded:: 4.3 @@ -410,38 +483,49 @@ Symfony provides the following env var processors: .. code-block:: yaml - # config/packages/framework.yaml + # config/services.yaml parameters: env(AUTH_FILE): '../config/auth.json' - google: - auth: '%env(trim:file:AUTH_FILE)%' + + services: + some_client: + $auth: '%env(trim:file:AUTH_FILE)%' .. code-block:: xml - + - + https://symfony.com/schema/dic/services/services-1.0.xsd" + > ../config/auth.json - + + + %env(trim:file:AUTH_FILE)% + + .. code-block:: php - // config/packages/framework.php - $container->setParameter('env(AUTH_FILE)', '../config/auth.json'); - $container->loadFromExtension('google', [ - 'auth' => '%env(trim:file:AUTH_FILE)%', - ]); + // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->parameters() + ->set('env(AUTH_FILE)', '../config/auth.json') + ; + + $container->services() + ->set('some_client') + ->arg('$auth', '%env(trim:file:AUTH_FILE)%') + ; + }; .. versionadded:: 4.3 @@ -458,8 +542,8 @@ Symfony provides the following env var processors: # config/services.yaml parameters: env(SECRETS_FILE): '/opt/application/.secrets.json' - database_password: '%env(key:database_password:json:file:SECRETS_FILE)%' # if SECRETS_FILE contents are: {"database_password": "secret"} it returns "secret" + database_password: '%env(key:database_password:json:file:SECRETS_FILE)%' .. code-block:: xml @@ -467,14 +551,13 @@ Symfony provides the following env var processors: - + https://symfony.com/schema/dic/services/services-1.0.xsd" + > /opt/application/.secrets.json + + %env(key:database_password:json:file:SECRETS_FILE)% @@ -482,8 +565,15 @@ Symfony provides the following env var processors: .. code-block:: php // config/services.php - $container->setParameter('env(SECRETS_FILE)', '/opt/application/.secrets.json'); - $container->setParameter('database_password', '%env(key:database_password:json:file:SECRETS_FILE)%'); + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->parameters() + ->set('env(SECRETS_FILE)', '/opt/application/.secrets.json') + // if SECRETS_FILE contents are: {"database_password": "secret"} it returns "secret" + ->set('database_password', '%env(key:database_password:json:file:SECRETS_FILE)%') + ; + }; ``env(default:fallback_param:BAR)`` Retrieves the value of the parameter ``fallback_param`` when the ``BAR`` env @@ -505,11 +595,9 @@ Symfony provides the following env var processors: + https://symfony.com/schema/dic/services/services-1.0.xsd" + > %env(default:raw_key:file:PRIVATE_KEY)% @@ -520,10 +608,15 @@ Symfony provides the following env var processors: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; - // if PRIVATE_KEY is not a valid file path, the content of raw_key is returned - $container->setParameter('private_key', '%env(default:raw_key:file:PRIVATE_KEY)%'); - $container->setParameter('raw_key', '%env(PRIVATE_KEY)%'); + return static function (ContainerConfigurator $container) { + $container->parameters() + // if PRIVATE_KEY is not a valid file path, the content of raw_key is returned + ->set('private_key', '%env(default:raw_key:file:PRIVATE_KEY)%') + ->set('raw_key', '%env(PRIVATE_KEY)%') + ; + }; When the fallback parameter is omitted (e.g. ``env(default::API_KEY)``), then the returned value is ``null``. @@ -544,7 +637,7 @@ Symfony provides the following env var processors: .. code-block:: yaml - # config/packages/mongodb.yaml + # config/packages/mongo_db_bundle.yaml mongo_db_bundle: clients: default: @@ -558,43 +651,58 @@ Symfony provides the following env var processors: .. code-block:: xml - + - - - - - - - + https://symfony.com/schema/dic/services/services-1.0.xsd + https://example.org/schema/dic/mongo-db-bundle + https://example.org/schema/dic/mongo-db-bundle/mongo-db-1.0.xsd" + > + + + + + + .. code-block:: php - // config/packages/mongodb.php - $container->loadFromExtension('mongodb', [ - 'clients' => [ - 'default' => [ - 'hosts' => [ - [ - 'host' => '%env(string:key:host:url:MONGODB_URL)%', - 'port' => '%env(int:key:port:url:MONGODB_URL)%', + // config/packages/mongo_db_bundle.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->extension('mongo_db_bundle', [ + 'clients' => [ + 'default' => [ + 'hosts' => [ + [ + 'host' => '%env(string:key:host:url:MONGODB_URL)%', + 'port' => '%env(int:key:port:url:MONGODB_URL)%', + ], ], + 'username' => '%env(string:key:user:url:MONGODB_URL)%', + 'password' => '%env(string:key:pass:url:MONGODB_URL)%', ], - 'username' => '%env(string:key:user:url:MONGODB_URL)%', - 'password' => '%env(string:key:pass:url:MONGODB_URL)%', ], - ], - 'connections' => [ - 'default' => [ - 'database_name' => '%env(key:path:url:MONGODB_URL)%', + 'connections' => [ + 'default' => [ + 'database_name' => '%env(key:path:url:MONGODB_URL)%', + ], ], - ], - ]); + ]); + }; .. caution:: @@ -618,38 +726,49 @@ Symfony provides the following env var processors: .. code-block:: yaml - # config/packages/mongodb.yaml + # config/packages/mongo_db_bundle.yaml mongo_db_bundle: clients: default: # ... - connectTimeoutMS: '%env(int:key:timeout:query_string:MONGODB_URL)%' + connect_timeout_ms: '%env(int:key:timeout:query_string:MONGODB_URL)%' .. code-block:: xml - + - - - - + https://symfony.com/schema/dic/services/services-1.0.xsd + https://example.org/schema/dic/mongo-db-bundle + https://example.org/schema/dic/mongo-db-bundle/mongo-db-1.0.xsd" + > + + + + + .. code-block:: php - // config/packages/mongodb.php - $container->loadFromExtension('mongodb', [ - 'clients' => [ - 'default' => [ - // ... - 'connectTimeoutMS' => '%env(int:key:timeout:query_string:MONGODB_URL)%', + // config/packages/mongo_db_bundle.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->extension('mongo_db_bundle', [ + 'clients' => [ + 'default' => [ + // ... + 'connect_timeout_ms' => '%env(int:key:timeout:query_string:MONGODB_URL)%', + ], ], - ], - ]); + ]); + }; .. versionadded:: 4.3 @@ -661,50 +780,69 @@ It is also possible to combine any number of processors: .. code-block:: yaml - # config/packages/framework.yaml + # config/services.yaml parameters: env(AUTH_FILE): "%kernel.project_dir%/config/auth.json" - google: + + services: + # ... + # 1. gets the value of the AUTH_FILE env var # 2. replaces the values of any config param to get the config path # 3. gets the content of the file stored in that path # 4. JSON-decodes the content of the file and returns it - auth: '%env(json:file:resolve:AUTH_FILE)%' + App\SomeAuthenticator: + $auth: '%env(json:file:resolve:AUTH_FILE)%' .. code-block:: xml - + - + https://symfony.com/schema/dic/services/services-1.0.xsd" + > %kernel.project_dir%/config/auth.json - - - - - + + + + + + + + + %env(json:file:resolve:AUTH_FILE)% + + .. code-block:: php - // config/packages/framework.php - $container->setParameter('env(AUTH_FILE)', '%kernel.project_dir%/config/auth.json'); - // 1. gets the value of the AUTH_FILE env var - // 2. replaces the values of any config param to get the config path - // 3. gets the content of the file stored in that path - // 4. JSON-decodes the content of the file and returns it - $container->loadFromExtension('google', [ - 'auth' => '%env(json:file:resolve:AUTH_FILE)%', - ]); + // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + use App\SomeAuthenticator; + + return static function (ContainerConfigurator $container) { + $container->parameters() + ->set('env(AUTH_FILE)', '%kernel.project_dir%/config/auth.json') + ; + + $container->services() + // ... + + // 1. gets the value of the AUTH_FILE env var + // 2. replaces the values of any config param to get the config path + // 3. gets the content of the file stored in that path + // 4. JSON-decodes the content of the file and returns it + ->set(SomeAuthenticator::class) + ->arg('$auth', '%env(json:file:resolve:AUTH_FILE)%') + ; + }; Custom Environment Variable Processors -------------------------------------- diff --git a/configuration/front_controllers_and_kernel.rst b/configuration/front_controllers_and_kernel.rst index b7b70456cb7..3441ebd1595 100644 --- a/configuration/front_controllers_and_kernel.rst +++ b/configuration/front_controllers_and_kernel.rst @@ -175,6 +175,7 @@ parameter used, for example, to turn Twig's debug mode on: .. code-block:: xml + - + https://symfony.com/schema/dic/twig/twig-1.0.xsd" + > - .. code-block:: php - $container->loadFromExtension('twig', [ - 'debug' => '%kernel.debug%', - // ... - ]); + // config/packages/twig.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->extension('twig', [ + 'debug' => '%kernel.debug%', + ]); + }; The Environments ---------------- diff --git a/configuration/micro_kernel_trait.rst b/configuration/micro_kernel_trait.rst index 16402bd5a54..4a42d713f3e 100644 --- a/configuration/micro_kernel_trait.rst +++ b/configuration/micro_kernel_trait.rst @@ -220,9 +220,11 @@ because the configuration started to get bigger: - + xsi:schemaLocation="http://symfony.com/schema/dic/services + https://symfony.com/schema/dic/services/services-1.0.xsd + http://symfony.com/schema/dic/symfony + https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" + > @@ -231,12 +233,16 @@ because the configuration started to get bigger: .. code-block:: php // config/framework.php - $container->loadFromExtension('framework', [ - 'secret' => 'S0ME_SECRET', - 'profiler' => [ - 'only_exceptions' => false, - ], - ]); + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->extension('framework', [ + 'secret' => 'S0ME_SECRET', + 'profiler' => [ + 'only_exceptions' => false, + ], + ]); + }; This also loads annotation routes from an ``src/Controller/`` directory, which has one file in it:: diff --git a/configuration/override_dir_structure.rst b/configuration/override_dir_structure.rst index a1af58ba5db..b426f848691 100644 --- a/configuration/override_dir_structure.rst +++ b/configuration/override_dir_structure.rst @@ -121,20 +121,25 @@ for multiple directories): xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/twig - https://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + https://symfony.com/schema/dic/twig/twig-1.0.xsd" + > + %kernel.project_dir%/resources/views - .. code-block:: php // config/packages/twig.php - $container->loadFromExtension('twig', [ - 'default_path' => '%kernel.project_dir%/resources/views', - ]); + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->extension('twig', [ + // ... + 'default_path' => '%kernel.project_dir%/resources/views', + ]); + }; Override the Translations Directory ----------------------------------- @@ -159,28 +164,33 @@ configuration option to define your own translations directory (use :ref:`framew - + http://symfony.com/schema/dic/symfony + https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" + > + %kernel.project_dir%/i18n - .. code-block:: php // config/packages/translation.php - $container->loadFromExtension('framework', [ - 'translator' => [ - 'default_path' => '%kernel.project_dir%/i18n', - ], - ]); + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->extension('framework', [ + 'translator' => [ + // ... + 'default_path'=> '%kernel.project_dir%/i18n', + ], + ]); + }; .. _override-web-dir: .. _override-the-web-directory: diff --git a/configuration/secrets.rst b/configuration/secrets.rst index 845a2106af7..f6b95116407 100644 --- a/configuration/secrets.rst +++ b/configuration/secrets.rst @@ -134,24 +134,30 @@ If you stored a ``DATABASE_PASSWORD`` secret, you can reference it by: xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/doctrine - https://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> - + https://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd" + > + - .. code-block:: php // config/packages/doctrine.php - $container->loadFromExtension('doctrine', [ - 'dbal' => [ - 'password' => '%env(DATABASE_PASSWORD)%', - ], - ]); + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->extension('framework', [ + 'dbal' => [ + 'password' => '%env(DATABASE_PASSWORD)%', + // ... + ], + // ... + ]); + }; The actual value will be resolved at runtime: container compilation and cache warmup don't need the **decryption key**. @@ -288,9 +294,9 @@ The secrets system is enabled by default and some of its behavior can be configu # config/packages/framework.yaml framework: secrets: - #vault_directory: '%kernel.project_dir%/config/secrets/%kernel.environment%' - #local_dotenv_file: '%kernel.project_dir%/.env.%kernel.environment%.local' - #decryption_env_var: 'base64:default::SYMFONY_DECRYPTION_SECRET' + vault_directory: '%kernel.project_dir%/config/secrets/%kernel.environment%' + local_dotenv_file: '%kernel.project_dir%/.env.%kernel.environment%.local' + decryption_env_var: 'base64:default::SYMFONY_DECRYPTION_SECRET' .. code-block:: xml @@ -299,10 +305,12 @@ The secrets system is enabled by default and some of its behavior can be configu - + loadFromExtension('framework', [ - 'secrets' => [ - // 'vault_directory' => '%kernel.project_dir%/config/secrets/%kernel.environment%', - // 'local_dotenv_file' => '%kernel.project_dir%/.env.%kernel.environment%.local', - // 'decryption_env_var' => 'base64:default::SYMFONY_DECRYPTION_SECRET', - ], - ]); - + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->extension('framework', [ + 'secrets' => [ + 'vault_directory' => '%kernel.project_dir%/config/secrets/%kernel.environment%', + 'local_dotenv_file' => '%kernel.project_dir%/.env.%kernel.environment%.local', + 'decryption_env_var' => 'base64:default::SYMFONY_DECRYPTION_SECRET', + ], + ]); + }; .. _`libsodium`: https://pecl.php.net/package/libsodium .. _`paragonie/sodium_compat`: https://github.com/paragonie/sodium_compat diff --git a/configuration/using_parameters_in_dic.rst b/configuration/using_parameters_in_dic.rst index 6bdf07ff886..d24516180c2 100644 --- a/configuration/using_parameters_in_dic.rst +++ b/configuration/using_parameters_in_dic.rst @@ -55,8 +55,8 @@ Now, examine the results to see this closely: xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://example.org/schema/dic/my_bundle - https://example.org/schema/dic/my_bundle/my_bundle-1.0.xsd"> - + https://example.org/schema/dic/my_bundle/my_bundle-1.0.xsd" + > @@ -74,25 +74,29 @@ Now, examine the results to see this closely: .. code-block:: php - $container->loadFromExtension('my_bundle', [ - 'logging' => true, - // true, as expected - ] - ); - - $container->loadFromExtension('my_bundle', [ - 'logging' => "%kernel.debug%", - // true/false (depends on 2nd parameter of Kernel), - // as expected, because %kernel.debug% inside configuration - // gets evaluated before being passed to the extension - ] - ); - - $container->loadFromExtension('my_bundle'); - // passes the string "%kernel.debug%". - // Which is always considered as true. - // The Configurator does not know anything about - // "%kernel.debug%" being a parameter. + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return static function (ContainerConfigurator $container) { + $container->extension('my_bundle', [ + 'logging' => true, + // true, as expected + ] + ); + + $container->extension('my_bundle', [ + 'logging' => "%kernel.debug%", + // true/false (depends on 2nd parameter of Kernel), + // as expected, because %kernel.debug% inside configuration + // gets evaluated before being passed to the extension + ] + ); + + $container->extension('my_bundle'); + // passes the string "%kernel.debug%". + // Which is always considered as true. + // The Configurator does not know anything about + // "%kernel.debug%" being a parameter. + }; In order to support this use case, the ``Configuration`` class has to be injected with this parameter via the extension as follows:: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy