8000 Tweak · symfony/symfony-docs@74d129d · GitHub
[go: up one dir, main page]

Skip to content

Commit 74d129d

Browse files
committed
Tweak
1 parent 4ccf907 commit 74d129d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

controller/service.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
How to Define Controllers as Services
55
=====================================
66

7-
In Symfony, a controller does *not* need to be registered as a service. But if you're
8-
using the :ref:`default services.yaml configuration <service-container-services-load-example>`,
9-
and that your controllers extend the `AbstractController`_ class,
10-
they *are* already registered as services. This means you can use dependency
11-
injection like any other normal service.
12-
13-
If your controllers don't extend the `AbstractController`_ class, you must explicitly mark your controller
14-
services as ``public``.
15-
Alternatively, you can also tag controller services with the ``controller.service_arguments``.
16-
This will make the tagged services ``public`` and will allow you to inject services in method parameters:
7+
In Symfony, a controller does *not* need to be registered as a service. But if
8+
you're using the :ref:`default services.yaml configuration <service-container-services-load-example>`,
9+
and your controllers extend the `AbstractController`_ class, they *are* automatically
10+
registered as services. This means you can use dependency injection like any
11+
other normal service.
12+
13+
If your controllers don't extend the `AbstractController`_ class, you must
14+
explicitly mark your controller services as ``public``. Alternatively, you can
15+
apply the ``controller.service_arguments`` tag to your controller services. This
16+
will make the tagged services ``public`` and will allow you to inject services
17+
in method parameters:
1718

1819
.. configuration-block::
1920

0 commit comments

Comments
 (0)
0