Skip to content

Navigation Menu

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 7069075

Browse filesBrowse files
committed
[#15990] Minor changes
1 parent fdd8b86 commit 7069075
Copy full SHA for 7069075

File tree

1 file changed

+23
-9
lines changed
Filter options

1 file changed

+23
-9
lines changed

‎messenger.rst

Copy file name to clipboardExpand all lines: messenger.rst
+23-9Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ serialized::
5050

5151
.. _messenger-handler:
5252

53+
.. versionadded:: 5.4
54+
55+
The ``#[AsMessageHandler]`` PHP attribute was introduced in Symfony
56+
5.4. PHP attributes require at least PHP 8.0.
57+
5358
A message handler is a PHP callable, the recommended way to create it is to
54-
create a class using :class:`Symfony\\Component\\Messenger\\Attribute\\AsMessageHandler`
55-
attribute which has an ``__invoke()`` method that's type-hinted with the
56-
message class (or a message interface) or you can create a class without the attribute, by implementing
57-
:class:`Symfony\\Component\\Messenger\\Handler\\MessageHandlerInterface`::
59+
create a class that has the :class:`Symfony\\Component\\Messenger\\Attribute\\AsMessageHandler`
60+
attribute and has an ``__invoke()`` method that's type-hinted with the
61+
message class (or a message interface)::
5862

5963
// src/MessageHandler/SmsNotificationHandler.php
6064
namespace App\MessageHandler;
@@ -71,6 +75,12 @@ message class (or a message interface) or you can create a class without the att
7175
}
7276
}
7377

78+
.. note::
79+
80+
You can also create a class without the attribute (e.g. if you're
81+
using PHP 7.4), by implementing :class:`Symfony\\Component\\Messenger\\Handler\\MessageHandlerInterface`
82+
instead.
83+
7484
Thanks to :ref:`autoconfiguration <services-autoconfigure>` and the ``SmsNotification``
7585
type-hint, Symfony knows that this handler should be called when an ``SmsNotification``
7686
message is dispatched. Most of the time, this is all you need to do. But you can
@@ -1770,12 +1780,15 @@ on a case-by-case basis via the :class:`Symfony\\Component\\Messenger\\Stamp\\Se
17701780
Customizing Handlers
17711781
--------------------
17721782

1773-
.. _messenger-handler-config:
1783+
Configuring Handlers Using Attributes
1784+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1785+
1786+
.. versionadded:: 5.4
17741787

1775-
Configuring Handlers Using Attribute
1776-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1788+
The ``#[AsMessageHandler]`` PHP attribute was introduced in Symfony
1789+
5.4. PHP attributes require at least PHP 8.0.
17771790

1778-
You can configure your handler easily by passing options to the attribute::
1791+
You can configure your handler by passing options to the attribute::
17791792

17801793
// src/MessageHandler/SmsNotificationHandler.php
17811794
namespace App\MessageHandler;
@@ -1793,7 +1806,6 @@ You can configure your handler easily by passing options to the attribute::
17931806
}
17941807
}
17951808

1796-
17971809
Possible options to configure with the attribute are:
17981810

17991811
* ``bus``
@@ -1802,6 +1814,8 @@ Possible options to configure with the attribute are:
18021814
* ``method``
18031815
* ``priority``
18041816

1817+
.. _messenger-handler-config:
1818+
18051819
Manually Configuring Handlers
18061820
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18071821

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.