@@ -254,6 +254,37 @@ file but also load a secondary one only if a certain parameter is set::
254254 }
255255 }
256256
257+ You are also able to deprecate container parameters in your extension to warn
258+ to not use a specific parameter anymore. This is particularly useful to help
259+ developers with the migration process across major versions of an extension.
260+ The deprecation can be done thanks to the ``ContainerBuilder::deprecateParameter ``
261+ method. This can only be achieved when configuring an extension with PHP, as this is
262+ not possible to do it with other configuration formats (YAML, XML). Let's define a
263+ parameter in our extension that will be declared as deprecated::
264+
265+ public function load(array $configs, ContainerBuilder $containerBuilder)
266+ {
267+ // ...
268+
269+ $containerBuilder->setParameter('acme_demo.database_user', $configs['db_user']);
270+
271+ $containerBuilder->deprecateParameter(
272+ 'acme_demo.database_user',
273+ 'acme/database-package',
274+ '1.3',
275+ // optionally you can set a custom deprecation message
276+ '"acme_demo.database_user" is deprecated, you should configure database credentials with the "acme_demo.database_dsn" parameter instead.'
277+ );
278+ }
279+
280+ The parameter being deprecated must be set before being declared as deprecated. Otherwise
281+ a :class: `Symfony\\ Component\\ DependencyInjection\\ Exception\\ ParameterNotFoundException ` exception
282+ will be thrown.
283+
284+ .. versionadded :: 6.3
285+
286+ The ``ContainerBuilder::deprecateParameter `` method was introduced in Symfony 6.3.
287+
257288.. note ::
258289
259290 Just registering an extension with the container is not enough to get
@@ -478,7 +509,7 @@ serves at dumping the compiled container::
478509 the :ref: `dumpFile() method <filesystem-dumpfile >` from Symfony Filesystem
479510 component or other methods provided by Symfony (e.g. ``$containerConfigCache->write() ``)
480511 which are atomic.
481-
512+
482513``ProjectServiceContainer `` is the default name given to the dumped container
483514class. However, you can change this with the ``class `` option when you
484515dump it::
0 commit comments