Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf99c17

Browse files
committed
Merge branch '4.2'
* 4.2: Fixed a minor syntax issue in a link [Messenger] Multiples buses, scoping handlers per bus, PSR-4 discovery & debug Added configuration for multiple buses
2 parents 6e6d126 + a4b6a8b commit bf99c17

File tree

4 files changed

+312
-109
lines changed

4 files changed

+312
-109
lines changed

components/messenger.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,5 +304,14 @@ loop, the message bus will add a :class:`Symfony\\Component\\Messenger\\Stamp\\R
304304
stamp to the message envelopes and the :class:`Symfony\\Component\\Messenger\\Middleware\\SendMessageMiddleware`
305305
middleware will know it should not route these messages again to a transport.
306306

307+
Learn more
308+
----------
309+
.. toctree::
310+
:maxdepth: 1
311+
:glob:
312+
313+
/messenger
314+
/messenger/*
315+
307316
.. _blog posts about command buses: https://matthiasnoback.nl/tags/command%20bus/
308317
.. _SimpleBus project: http://simplebus.io

console/coloring.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ output (e.g. important messages, titles, comments, etc.).
99
By default, the Windows command console doesn't support output coloring. The
1010
Console component disables output coloring for Windows systems, but if your
1111
commands invoke other scripts which emit color sequences, they will be
12-
wrongly displayed as raw escape characters. Install the `Cmder`_, `ConEmu`_, `ANSICON`_
13-
,`Mintty`_ (used by default in GitBash and Cygwin) or `Hyper`_ free applications
14-
to add coloring support to your Windows command console.
12+
wrongly displayed as raw escape characters. Install the `Cmder`_, `ConEmu`_,
13+
`ANSICON`_, `Mintty`_ (used by default in GitBash and Cygwin) or `Hyper`_
14+
free applications to add coloring support to your Windows command console.
1515

1616
Using Color Styles
1717
------------------

messenger.rst

Lines changed: 8 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -423,112 +423,6 @@ your ``transports`` configuration or it can be your own receiver.
423423
It also requires a ``--bus`` option in case you have multiple buses configured,
424424
which is the name of the bus to which received messages should be dispatched.
425425

426-
Multiple Buses
427-
--------------
428-
429-
If you are interested in architectures like CQRS, you might want to have multiple
430-
buses within your application.
431-
432-
You can create multiple buses (in this example, a command bus and an event bus) like
433-
this:
434-
435-
.. configuration-block::
436-
437-
.. code-block:: yaml
438-
439-
# config/packages/messenger.yaml
440-
framework:
441-
messenger:
442-
# The bus that is going to be injected when injecting MessageBusInterface:
443-
default_bus: messenger.bus.commands
444-
445-
# Create buses
446-
buses:
447-
messenger.bus.commands: ~
448-
messenger.bus.events: ~
449-
450-
.. code-block:: xml
451-
452-
<!-- config/packages/messenger.xml -->
453-
<?xml version="1.0" encoding="UTF-8" ?>
454-
<container xmlns="http://symfony.com/schema/dic/services"
455-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
456-
xmlns:framework="http://symfony.com/schema/dic/symfony"
457-
xsi:schemaLocation="http://symfony.com/schema/dic/services
458-
http://symfony.com/schema/dic/services/services-1.0.xsd
459-
http://symfony.com/schema/dic/symfony
460-
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
461-
462-
<framework:config>
463-
<framework:messenger default-bus="messenger.bus.commands">
464-
<framework:bus name="messenger.bus.commands" />
465-
<framework:bus name="messenger.bus.events" />
466-
</framework:messenger>
467-
</framework:config>
468-
</container>
469-
470-
.. code-block:: php
471-
472-
// config/packages/messenger.php
473-
$container->loadFromExtension('framework', array(
474-
'messenger' => array(
475-
'default_bus' => 'messenger.bus.commands',
476-
'buses' => array(
477-
'messenger.bus.commands' => null,
478-
'messenger.bus.events' => null,
479-
),
480-
),
481-
));
482-
483-
This will generate the ``messenger.bus.commands`` and ``messenger.bus.events`` services
484-
that you can inject in your services.
485-
486-
.. note::
487-
488-
To register a handler only for a specific bus, add a ``bus`` attribute to
489-
the handler's service tag (``messenger.message_handler``) and use the bus
490-
name as its value.
491-
492-
Type-hints and Auto-wiring
493-
~~~~~~~~~~~~~~~~~~~~~~~~~~
494-
495-
Auto-wiring is a great feature that allows you to reduce the amount of configuration
496-
required for your service container to be created. When using multiple buses, by default,
497-
the auto-wiring will not work as it won't know which bus to inject in your own services.
498-
499-
In order to clarify this, you can use the DependencyInjection's binding capabilities
500-
to clarify which bus will be injected based on the argument's name:
501-
502-
.. configuration-block::
503-
504-
.. code-block:: yaml
505-
506-
# config/services.yaml
507-
services:
508-
_defaults:
509-
# ...
510-
511-
bind:
512-
$commandBus: '@messenger.bus.commands'
513-
$eventBus: '@messenger.bus.events'
514-
515-
.. code-block:: xml
516-
517-
<!-- config/services.xml -->
518-
<?xml version="1.0" encoding="UTF-8" ?>
519-
<container xmlns="http://symfony.com/schema/dic/services"
520-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
521-
xsi:schemaLocation="http://symfony.com/schema/dic/services
522-
http://symfony.com/schema/dic/services/services-1.0.xsd">
523-
524-
<services>
525-
<defaults>
526-
<bind key="$commandBus" type="service" id="messenger.bus.commands" />
527-
<bind key="$commandBus" type="service" id="messenger.bus.events" />
528-
</defaults>
529-
</services>
530-
</container>
531-
532426
Middleware
533427
----------
534428

@@ -928,4 +822,12 @@ will give you access to the following services:
928822
#. ``messenger.sender.yours``: the sender;
929823
#. ``messenger.receiver.yours``: the receiver.
930824

825+
Learn more
826+
----------
827+
.. toctree::
828+
:maxdepth: 1
829+
:glob:
830+
831+
/messenger/*
832+
931833
.. _`enqueue's transport`: https://github.com/php-enqueue/messenger-adapter

0 commit comments

Comments
 (0)