Skip to content

Commit ea69b78

Browse files
[DependencyInjection] Enable deprecating parameters
1 parent 740e44f commit ea69b78

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Configuration Formats
5858
~~~~~~~~~~~~~~~~~~~~~
5959

6060
Unlike other frameworks, Symfony doesn't impose a specific format on you to
61-
configure your applications, but lets you choose between YAML, XML and PHP.
61+
configure your applications, but lets you choose between YAML, XML and PHP.
6262
Throughout the Symfony documentation, all configuration examples will be
6363
shown in these three formats.
6464

service_container.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,23 @@ accessor methods for parameters::
607607
To learn more about compiling the container see
608608
:doc:`/components/dependency_injection/compilation`.
609609

610+
It is also possible to deprecate a container parameter. This is particularly useful
611+
if you're writing your own package and want to warn developers to not use a parameter anymore
612+
because it will be removed in one of the next version of your package.
613+
Deprecating a container parameter can be done as follow::
614+
615+
$container->deprecateParameter(
616+
'vendor.database_user',
617+
'vendor-name/package-name',
618+
'1.3',
619+
// optionally you can set a custom deprecation message
620+
'"vendor.database_user" is deprecated, you should configure database credentials in "vendor.database_dsn" parameter instead.'
621+
);
622+
623+
.. versionadded:: 6.3
624+
625+
The ``ContainerBuilder::deprecateParameter`` method was introduced in Symfony 6.3.
626+
610627
.. _services-wire-specific-service:
611628

612629
Choose a Specific Service

0 commit comments

Comments
 (0)