Skip to content

Add the missing note on how to inject a service into the controller #20117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ These are used for rendering templates, sending emails, querying the database an
any other "work" you can think of.

If you need a service in a controller, type-hint an argument with its class
(or interface) name. Symfony will automatically pass you the service you need::
(or interface) name. Symfony will automatically pass you the service you need.
Make sure your :doc:`controller is registered as a service </controller/service>`::

use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
Expand Down
Loading