Skip to content

Commit 3d9dfe6

Browse files
committed
[DependencyInjection] Document ServiceConfigurator remove method
1 parent 0bb8fe2 commit 3d9dfe6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

service_container/remove.rst

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
How to Remove a Service
2+
=======================
3+
4+
A service can be removed from the service container if needed
5+
(for instance in the test or a specific environment):
6+
7+
.. configuration-block::
8+
9+
.. code-block:: php
10+
11+
// config/services_test.php
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use App\RemovedService;
15+
16+
return function(ContainerConfigurator $containerConfigurator) {
17+
$services = $containerConfigurator->services();
18+
19+
$services->remove(RemovedService::class);
20+
};
21+
22+
Now, the container will not contain the ``App\RemovedService``
23+
in the test environment.

0 commit comments

Comments
 (0)