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 ec267d1

Browse filesBrowse files
committed
[Messenger] Describe the doctrine tranport
1 parent 5dc1c9f commit ec267d1
Copy full SHA for ec267d1

File tree

1 file changed

+106
-0
lines changed
Filter options

1 file changed

+106
-0
lines changed

‎messenger/doctrine-transport.rst

Copy file name to clipboard
+106Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
.. index::
2+
single: Messenger; Use doctrine as a transport
3+
4+
Use Doctrine as transport
5+
=========================
6+
7+
The Messenger component comes with a Doctrine transport. This lets doctrine handle the storage of your messages. To use it you need to define the transport as the following:
8+
9+
.. configuration-block::
10+
11+
.. code-block:: yaml
12+
13+
# config/packages/messenger.yaml
14+
framework:
15+
messenger:
16+
transports:
17+
doctrine: "doctrine://default"
18+
19+
.. code-block:: xml
20+
21+
<!-- config/packages/messenger.xml -->
22+
<?xml version="1.0" encoding="UTF-8" ?>
23+
<container xmlns="http://symfony.com/schema/dic/services"
24+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
25+
xmlns:framework="http://symfony.com/schema/dic/symfony"
26+
xsi:schemaLocation="http://symfony.com/schema/dic/services
27+
http://symfony.com/schema/dic/services/services-1.0.xsd
28+
http://symfony.com/schema/dic/symfony
29+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
30+
31+
<framework:config>
32+
<framework:messenger>
33+
<framework:transport name="doctrine" dsn="doctrine://default" />
34+
</framework:messenger>
35+
</framework:config>
36+
</container>
37+
38+
.. code-block:: php
39+
40+
// config/packages/messenger.php
41+
$container->loadFromExtension('framework', array(
42+
'messenger' => array(
43+
'transports' => array(
44+
'doctrine' => 'doctrine://default',
45+
),
46+
),
47+
));
48+
49+
The format of the DSN is `doctrine://<connection_name>`. The connection name is the name you used in the doctrine configuration. If you only use one connection then use `default`.
50+
51+
Customize table name
52+
--------------------
53+
54+
By default the transport will create a table named `messenger_messages` but you can configure it per transport:
55+
56+
.. configuration-block::
57+
58+
.. code-block:: yaml
59+
60+
# config/packages/messenger.yaml
61+
framework:
62+
messenger:
63+
transports:
64+
doctrine:
65+
dsn: "doctrine://default"
66+
options: {table_name: "custom_table_name_for_messages"}
67+
68+
.. code-block:: xml
69+
70+
<!-- config/packages/messenger.xml -->
71+
<?xml version="1.0" encoding="UTF-8" ?>
72+
<container xmlns="http://symfony.com/schema/dic/services"
73+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
74+
xmlns:framework="http://symfony.com/schema/dic/symfony"
75+
xsi:schemaLocation="http://symfony.com/schema/dic/services
76+
http://symfony.com/schema/dic/services/services-1.0.xsd
77+
http://symfony.com/schema/dic/symfony
78+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
79+
80+
<framework:config>
81+
<framework:messenger>
82+
<framework:transport name="doctrine" dsn="doctrine://default">
83+
<framework:option table_name="custom_table_name_for_messages" />
84+
</framework:transport>
85+
</framework:messenger>
86+
</framework:config>
87+
</container>
88+
89+
.. code-block:: php
90+
91+
// config/packages/messenger.php
92+
$container->loadFromExtension('framework', array(
93+
'messenger' => array(
94+
'transports' => array(
95+
'doctrine' => array(
96+
'dsn' => 'doctrine://default',
97+
'options' => array('table_name' => 'custom_table_name_for_messages'),
98+
),
99+
),
100+
),
101+
));
102+
103+
Working with multiple connections
104+
---------------------------------
105+
106+
If you have multiple Doctrine connections defined you can choose the desired one. If you have a connection named `legacy` the you should use the following DSN : `doctrine://legacy`.

0 commit comments

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