8000 Add autoconfiguration note for MessageHandlers · symfony/symfony-docs@957b691 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 957b691

Browse files
Steveb-pjaviereguiluz
authored andcommitted
Add autoconfiguration note for MessageHandlers
1 parent c3f8c85 commit 957b691

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

messenger.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,23 @@ message handler. It's a class with an ``__invoke`` method::
4848

4949
// src/MessageHandler/MyMessageHandler.php
5050
namespace App\MessageHandler;
51+
52+
use Symfony\Component\Messenger\Handler;
5153

52-
class MyMessageHandler
54+
class MyMessageHandler implements MessageHandlerInterface
5355
{
5456
public function __invoke(MyMessage $message)
5557
{
5658
// do something with it.
5759
}
5860
}
5961

60-
Once you've created your handler, you need to register it:
62+
Message handlers must be registered as services and :doc:`tagged </service_container/tags>`
63+
with the ``messenger.message_handler`` tag. If you're using the
64+
:ref:`default services.yaml configuration <service-container-services-load-example>`,
65+
this is already done for you, thanks to :ref:`autoconfiguration <services-autoconfigure>`.
66+
67+
If you're not using autoconfigure functionality, then you need to register it:
6168

6269
.. configuration-block::
6370

0 commit comments

Comments
 (0)
0