Skip to content

Commit 1935e26

Browse files
committed
Merge branch '4.3'
* 4.3: Fix PHP-CS link Update serializer.rst [#11341] Added versionadded directive Add documentation for the Redis transport Typo Fix usage of StaticJwtProvider added a note about testing newer versions of Symfony fix indention
2 parents 0af8ec9 + 898a6c1 commit 1935e26

File tree

7 files changed

+82
-32
lines changed

7 files changed

+82
-32
lines changed

cache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ and use that when configuring the pool.
321321
factory: ['Symfony\Component\Cache\Adapter\RedisAdapter', 'createConnection']
322322
arguments:
323323
- 'redis://localhost'
324-
- [ retry_interval: 2, timeout: 10 ]
324+
- { retry_interval: 2, timeout: 10 }
325325
326326
.. code-block:: xml
327327

components/mercure.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ The following example shows the component in action::
3131
define('HUB_URL', 'https://demo.mercure.rocks/hub');
3232
define('JWT', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJmb28iLCJiYXIiXSwicHVibGlzaCI6WyJmb28iXX19.LRLvirgONK13JgacQ_VbcjySbVhkSmHy3IznH3tA9PM');
3333

34-
use Symfony\Component\Mercure\Jwt\StaticJwtProvide;
34+
use Symfony\Component\Mercure\Jwt\StaticJwtProvider;
3535
use Symfony\Component\Mercure\Publisher;
3636
use Symfony\Component\Mercure\Update;
3737

38-
$publisher = new Publisher(HUB_URL, new StaticJwtProvide(JWT));
38+
$publisher = new Publisher(HUB_URL, new StaticJwtProvider(JWT));
3939
// Serialize the update, and dispatch it to the hub, that will broadcast it to the clients
4040
$id = $publisher(new Update('https://example.com/books/1.jsonld', 'Hi from Symfony!', ['target1', 'target2']));
4141

components/messenger.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ do is to write your own CSV receiver::
272272

273273
public function __construct(SerializerInterface $serializer, string $filePath)
274274
{
275-
$this->serializer = $serializer;
276-
$this->filePath = $filePath;
275+
$this->serializer = $serializer;
276+
$this->filePath = $filePath;
277277
}
278278

279279
public function receive(callable $handler): void

components/serializer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ key in the ``context`` parameter of the desired serializer method::
432432
$encoder = new JsonEncoder();
433433

434434
$serializer = new Serializer([$normalizer], [$encoder]);
435-
$serializer->serialize($person, 'json', ['ignored_attributes' => 'age']); // Output: {"name":"foo"}
435+
$serializer->serialize($person, 'json', ['ignored_attributes' => ['age']]); // Output: {"name":"foo"}
436436

437437
.. deprecated:: 4.2
438438

contributing/code/standards.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ License
276276
* Symfony is released under the MIT license, and the license block has to be
277277
present at the top of every PHP file, before the namespace.
278278

279-
.. _`PHP CS Fixer tool`: http://cs.sensiolabs.org/
279+
.. _`PHP CS Fixer tool`: https://cs.symfony.com/
280280
.. _`PSR-0`: https://www.php-fig.org/psr/psr-0/
281281
.. _`PSR-1`: https://www.php-fig.org/psr/psr-1/
282282
.. _`PSR-2`: https://www.php-fig.org/psr/psr-2/

messenger.rst

Lines changed: 64 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,12 @@ Transports
135135
By default, messages are processed as soon as they are dispatched. If you prefer
136136
to process messages asynchronously, you must configure a transport. These
137137
transports communicate with your application via queuing systems or third parties.
138-
The built-in AMQP transport allows you to communicate with most of the AMQP
139-
brokers such as RabbitMQ.
138+
139+
There are the following built-in transports:
140+
141+
- `AMQP`_
142+
- Doctrine
143+
- `Redis`_
140144

141145
.. note::
142146

@@ -155,7 +159,7 @@ the messenger component, the following configuration should have been created:
155159
framework:
156160
messenger:
157161
transports:
158-
amqp: "%env(MESSENGER_TRANSPORT_DSN)%"
162+
your_transport: "%env(MESSENGER_TRANSPORT_DSN)%"
159163
160164
.. code-block:: xml
161165
@@ -171,7 +175,7 @@ the messenger component, the following configuration should have been created:
171175
172176
<framework:config>
173177
<framework:messenger>
174-
<framework:transport name="amqp" dsn="%env(MESSENGER_TRANSPORT_DSN)%"/>
178+
<framework:transport name="your_transport" dsn="%env(MESSENGER_TRANSPORT_DSN)%"/>
175179
</framework:messenger>
176180
</framework:config>
177181
</container>
@@ -182,33 +186,67 @@ the messenger component, the following configuration should have been created:
182186
$container->loadFromExtension('framework', [
183187
'messenger' => [
184188
'transports' => [
185-
'amqp' => '%env(MESSENGER_TRANSPORT_DSN)%',
189+
'your_transport' => '%env(MESSENGER_TRANSPORT_DSN)%',
186190
],
187191
],
188192
]);
189193
194+
This will also configure the following services for you:
195+
196+
#. A ``messenger.sender.your_transport`` sender to be used when routing messages;
197+
#. A ``messenger.receiver.your_transport`` receiver to be used when consuming messages.
198+
199+
Now define the ``MESSENGER_TRANSPORT_DSN`` in the ``.env`` file.
200+
See examples beneath how to configure the DSN for different transports.
201+
202+
AMQP
203+
~~~~
204+
190205
.. code-block:: bash
191206
192207
# .env
193-
###> symfony/messenger ###
194208
MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
195-
###< symfony/messenger ###
196209
197210
This is enough to allow you to route your message to the ``amqp`` transport.
198-
This will also configure the following services for you:
199-
200-
#. A ``messenger.sender.amqp`` sender to be used when routing messages;
201-
#. A ``messenger.receiver.amqp`` receiver to be used when consuming messages.
202211

203212
.. note::
204213

205214
In order to use Symfony's built-in AMQP transport, you will need the AMQP
206-
PHP extension and the Serializer Component. Ensure that they are installed with:
215+
PHP extension and the Serializer component. Ensure that they are installed with:
207216

208217
.. code-block:: terminal
209218
210219
$ composer require symfony/amqp-pack
211220
221+
Redis
222+
~~~~~
223+
224+
.. versionadded:: 4.3
225+
226+
The Redis transport was introduced in Symfony 4.3.
227+
228+
The Redis transport will use `streams`_ to queue messages.
229+
230+
.. code-block:: bash
231+
232+
# .env
233+
MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
234+
235+
This is enough to allow you to route your message to the Redis transport.
236+
237+
If you have multiple systems to receive the same messages you could use different groups
238+
to achieve this:
239+
240+
.. code-block:: bash
241+
242+
# .env
243+
MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages/group1/consumer1
244+
245+
.. note::
246+
247+
In order to use Symfony's built-in Redis transport, you will need the Redis
248+
PHP extension (^4.2), a running Redis server (^5.0) and the Serializer component.
249+
212250
Routing
213251
-------
214252

@@ -225,7 +263,7 @@ configuration:
225263
framework:
226264
messenger:
227265
routing:
228-
'My\Message\Message': amqp # The name of the defined transport
266+
'My\Message\Message': your_transport # The name of the defined transport
229267
230268
.. code-block:: xml
231269
@@ -242,7 +280,7 @@ configuration:
242280
<framework:config>
243281
<framework:messenger>
244282
<framework:routing message-class="My\Message\Message">
245-
<framework:sender service="amqp"/>
283+
<framework:sender service="your_transport"/>
246284
</framework:routing>
247285
</framework:messenger>
248286
</framework:config>
@@ -254,7 +292,7 @@ configuration:
254292
$container->loadFromExtension('framework', [
255293
'messenger' => [
256294
'routing' => [
257-
'My\Message\Message' => 'amqp',
295+
'My\Message\Message' => 'your_transport',
258296
],
259297
],
260298
]);
@@ -274,7 +312,7 @@ instead of a class name:
274312
messenger:
275313
routing:
276314
'My\Message\MessageAboutDoingOperationalWork': another_transport
277-
'*': amqp
315+
'*': your_transport
278316
279317
.. code-block:: xml
280318
@@ -294,7 +332,7 @@ instead of a class name:
294332
<framework:sender service="another_transport"/>
295333
</framework:routing>
296334
<framework:routing message-class="*">
297-
<framework:sender service="amqp"/>
335+
<framework:sender service="your_transport"/>
298336
</framework:routing>
299337
</framework:messenger>
300338
</framework:config>
@@ -307,7 +345,7 @@ instead of a class name:
307345
'messenger' => [
308346
'routing' => [
309347
'My\Message\Message' => 'another_transport',
310-
'*' => 'amqp',
348+
'*' => 'your_transport',
311349
],
312350
],
313351
]);
@@ -322,7 +360,7 @@ A class of messages can also be routed to multiple senders by specifying a list:
322360
framework:
323361
messenger:
324362
routing:
325-
'My\Message\ToBeSentToTwoSenders': [amqp, audit]
363+
'My\Message\ToBeSentToTwoSenders': [your_transport, audit]
326364
327365
.. code-block:: xml
328366
@@ -339,7 +377,7 @@ A class of messages can also be routed to multiple senders by specifying a list:
339377
<framework:config>
340378
<framework:messenger>
341379
<framework:routing message-class="My\Message\ToBeSentToTwoSenders">
342-
<framework:sender service="amqp"/>
380+
<framework:sender service="your_transport"/>
343381
<framework:sender service="audit"/>
344382
</framework:routing>
345383
</framework:messenger>
@@ -352,7 +390,7 @@ A class of messages can also be routed to multiple senders by specifying a list:
352390
$container->loadFromExtension('framework', [
353391
'messenger' => [
354392
'routing' => [
355-
'My\Message\ToBeSentToTwoSenders' => ['amqp', 'audit'],
393+
'My\Message\ToBeSentToTwoSenders' => ['your_transport', 'audit'],
356394
],
357395
],
358396
]);
@@ -369,7 +407,7 @@ while still having them passed to their respective handler:
369407
messenger:
370408
routing:
371409
'My\Message\ThatIsGoingToBeSentAndHandledLocally':
372-
senders: [amqp]
410+
senders: [your_transport]
373411
send_and_handle: true
374412
375413
.. code-block:: xml
@@ -387,7 +425,7 @@ while still having them passed to their respective handler:
387425
<framework:config>
388426
<framework:messenger>
389427
<framework:routing message-class="My\Message\ThatIsGoingToBeSentAndHandledLocally" send-and-handle="true">
390-
<framework:sender service="amqp"/>
428+
<framework:sender service="your_transport"/>
391429
</framework:routing>
392430
</framework:messenger>
393431
</framework:config>
@@ -400,7 +438,7 @@ while still having them passed to their respective handler:
400438
'messenger' => [
401439
'routing' => [
402440
'My\Message\ThatIsGoingToBeSentAndHandledLocally' => [
403-
'senders' => ['amqp'],
441+
'senders' => ['your_transport'],
404442
'send_and_handle' => true,
405443
],
406444
],
@@ -415,7 +453,7 @@ most of the cases. To do so, use the ``messenger:consume`` command like this:
415453

416454
.. code-block:: terminal
417455
418-
$ php bin/console messenger:consume amqp
456+
$ php bin/console messenger:consume your_transport
419457
420458
The first argument is the receiver's service name. It might have been created by
421459
your ``transports`` configuration or it can be your own receiver.
@@ -835,3 +873,4 @@ Learn more
835873
/messenger/*
836874

837875
.. _`enqueue's transport`: https://github.com/php-enqueue/messenger-adapter
876+
.. _`streams`: https://redis.io/topics/streams-intro

setup/symfony_server.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,17 @@ commands from the Symfony server:
348348
# creates a new project based on symfony/demo
349349
$ symfony new --demo my_project_name
350350
351+
You can create a project depending on a **development** version as well (note
352+
that Composer will also set the stability to ``dev`` for all root dependencies):
353+
354+
.. code-block:: terminal
355+
356+
# creates a new project based on Symfony's master branch
357+
$ symfony new --version=dev-master my_project_name
358+
359+
# creates a new project based on Symfony's 4.3 dev branch
360+
$ symfony new --version=4.3.x-dev my_project_name
361+
351362
.. _`symfony.com/download`: https://symfony.com/download
352363
.. _`different ways of installing Symfony`: https://symfony.com/download
353364
.. _`Docker`: https://en.wikipedia.org/wiki/Docker_(software)

0 commit comments

Comments
 (0)