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 01dc25c

Browse filesBrowse files
committed
[Reference] consistent & complete config examples
1 parent 041105c commit 01dc25c
Copy full SHA for 01dc25c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

41 files changed

+619
-331
lines changed

‎reference/configuration/doctrine.rst

Copy file name to clipboardExpand all lines: reference/configuration/doctrine.rst
+31-26Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -356,32 +356,37 @@ The following block shows all possible configuration keys:
356356
357357
.. code-block:: xml
358358
359-
<!-- xmlns:doctrine="http://symfony.com/schema/dic/doctrine" -->
360-
<!-- xsi:schemaLocation="http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> -->
361-
362-
<doctrine:config>
363-
<doctrine:dbal
364-
name="default"
365-
dbname="database"
366-
host="localhost"
367-
port="1234"
368-
user="user"
369-
password="secret"
370-
driver="pdo_mysql"
371-
driver-class="MyNamespace\MyDriverImpl"
372-
path="%kernel.data_dir%/data.sqlite"
373-
memory="true"
374-
unix-socket="/tmp/mysql.sock"
375-
wrapper-class="MyDoctrineDbalConnectionWrapper"
376-
charset="UTF8"
377-
logging="%kernel.debug%"
378-
platform-service="MyOwnDatabasePlatformService"
379-
>
380-
<doctrine:option key="foo">bar</doctrine:option>
381-
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
382-
<doctrine:type name="custom">Acme\HelloBundle\MyCustomType</doctrine:type>
383-
</doctrine:dbal>
384-
</doctrine:config>
359+
<?xml version="1.0" encoding="UTF-8" ?>
360+
<container xmlns="http://symfony.com/schema/dic/services"
361+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
362+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
363+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
364+
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
365+
366+
<doctrine:config>
367+
<doctrine:dbal
368+
name="default"
369+
dbname="database"
370+
host="localhost"
371+
port="1234"
372+
user="user"
373+
password="secret"
374+
driver="pdo_mysql"
375+
driver-class="MyNamespace\MyDriverImpl"
376+
path="%kernel.data_dir%/data.sqlite"
377+
memory="true"
378+
unix-socket="/tmp/mysql.sock"
379+
wrapper-class="MyDoctrineDbalConnectionWrapper"
380+
charset="UTF8"
381+
logging="%kernel.debug%"
382+
platform-service="MyOwnDatabasePlatformService">
383+
384+
<doctrine:option key="foo">bar</doctrine:option>
385+
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
386+
<doctrine:type name="custom">Acme\HelloBundle\MyCustomType</doctrine:type>
387+
</doctrine:dbal>
388+
</doctrine:config>
389+
</container>
385390
386391
If you want to configure multiple connections in YAML, put them under the
387392
``connections`` key and give them a unique name:

‎reference/configuration/framework.rst

Copy file name to clipboardExpand all lines: reference/configuration/framework.rst
+45-14Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,26 @@ have installed `PhpStormOpener`_ and use PHPstorm, you will do something like:
101101

102102
.. code-block:: yaml
103103
104+
# app/config/config.yml
104105
framework:
105106
ide: "pstorm://%%f:%%l"
106107
107108
.. code-block:: xml
108109
109-
<?xml version="1.0" charset="UTF-8" ?>
110-
<container xmlns="http://symfony.com/schema/dic/service"
111-
xmlns:framework="http://symfony.com/schema/dic/symfony">
110+
<!-- app/config/config.xml -->
111+
<?xml version="1.0" encoding="UTF-8" ?>
112+
<container xmlns="http://symfony.com/schema/dic/services"
113+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
114+
xmlns:framework="http://symfony.com/schema/dic/symfony"
115+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
116+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
112117
113118
<framework:config ide="pstorm://%%f:%%l" />
114-
115119
</container>
116120
117121
.. code-block:: php
118122
123+
// app/config/config.php
119124
$container->loadFromExtension('framework', array(
120125
'ide' => 'pstorm://%%f:%%l',
121126
));
@@ -155,17 +160,26 @@ see :doc:`/cookbook/request/load_balancer_reverse_proxy`.
155160

156161
.. code-block:: yaml
157162
163+
# app/config/config.yml
158164
framework:
159165
trusted_proxies: [192.0.0.1, 10.0.0.0/8]
160166
161167
.. code-block:: xml
162168
163-
<framework:config trusted-proxies="192.0.0.1, 10.0.0.0/8">
164-
<!-- ... -->
165-
</framework>
169+
<!-- app/config/config.xml -->
170+
<?xml version="1.0" encoding="UTF-8" ?>
171+
<container xmlns="http://symfony.com/schema/dic/services"
172+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
173+
xmlns:framework="http://symfony.com/schema/dic/symfony"
174+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
175+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
176+
177+
<framework:config trusted-proxies="192.0.0.1, 10.0.0.0/8" />
178+
</container>
166179
167180
.. code-block:: php
168181
182+
// app/config/config.php
169183
$container->loadFromExtension('framework', array(
170184
'trusted_proxies' => array('192.0.0.1', '10.0.0.0/8'),
171185
));
@@ -282,9 +296,17 @@ the value to ``null``:
282296
.. code-block:: xml
283297
284298
<!-- app/config/config.xml -->
285-
<framework:config>
286-
<framework:session save-path="null" />
287-
</framework:config>
299+
<?xml version="1.0" encoding="UTF-8" ?>
300+
<container xmlns="http://symfony.com/schema/dic/services"
301+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
302+
xmlns:framework="http://symfony.com/schema/dic/symfony"
303+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
304+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
305+
306+
<framework:config>
307+
<framework:session save-path="null" />
308+
</framework:config>
309+
</container>
288310
289311
.. code-block:: php
290312
@@ -370,15 +392,24 @@ Now, activate the ``assets_version`` option:
370392
.. code-block:: xml
371393
372394
<!-- app/config/config.xml -->
373-
<framework:templating assets-version="v2">
374-
<framework:engine id="twig" />
375-
</framework:templating>
395+
<?xml version="1.0" encoding="UTF-8" ?>
396+
<container xmlns="http://symfony.com/schema/dic/services"
397+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
398+
xmlns:framework="http://symfony.com/schema/dic/symfony"
399+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
400+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
401+
402+
<framework:templating assets-version="v2">
403+
<!-- ... -->
404+
<framework:engine>twig</framework:engine>
405+
</framework:templating>
406+
</container>
376407
377408
.. code-block:: php
378409
379410
// app/config/config.php
380411
$container->loadFromExtension('framework', array(
381-
...,
412+
// ...
382413
'templating' => array(
383414
'engines' => array('twig'),
384415
'assets_version' => 'v2',

‎reference/configuration/swiftmailer.rst

Copy file name to clipboardExpand all lines: reference/configuration/swiftmailer.rst
+29-23Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -200,29 +200,35 @@ Full default Configuration
200200
201201
.. code-block:: xml
202202
203-
<swiftmailer:config
204-
transport="smtp"
205-
username=""
206-
password=""
207-
host="localhost"
208-
port="false"
209-
encryption=""
210-
auth_mode=""
211-
sender_address=""
212-
delivery_address=""
213-
disable_delivery=""
214-
logging="%kernel.debug%"
215-
>
216-
<swiftmailer:spool
217-
path="%kernel.cache_dir%/swiftmailer/spool"
218-
type="file"
219-
/>
220-
221-
<swiftmailer:antiflood
222-
sleep="0"
223-
threshold="99"
224-
/>
225-
</swiftmailer:config>
203+
<?xml version="1.0" encoding="UTF-8" ?>
204+
<container xmlns="http://symfony.com/schema/dic/services"
205+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
206+
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
207+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
208+
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">
209+
210+
<swiftmailer:config
211+
transport="smtp"
212+
username=""
213+
password=""
214+
host="localhost"
215+
port="false"
216+
encryption=""
217+
auth_mode=""
218+
sender_address=""
219+
delivery_address=""
220+
disable_delivery=""
221+
logging="%kernel.debug%"
222+
>
223+
<swiftmailer:spool
224+
path="%kernel.cache_dir%/swiftmailer/spool"
225+
type="file" />
226+
227+
<swiftmailer:antiflood
228+
sleep="0"
229+
threshold="99" />
230+
</swiftmailer:config>
231+
</container>
226232
227233
Using multiple Mailers
228234
----------------------

‎reference/constraints/All.rst

Copy file name to clipboardExpand all lines: reference/constraints/All.rst
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ entry in that array:
2424

2525
.. code-block:: yaml
2626
27-
# src/UserBundle/Resources/config/validation.yml
27+
# src/Acme/UserBundle/Resources/config/validation.yml
2828
Acme\UserBundle\Entity\User:
2929
properties:
3030
favoriteColors:
@@ -37,15 +37,15 @@ entry in that array:
3737
3838
// src/Acme/UserBundle/Entity/User.php
3939
namespace Acme\UserBundle\Entity;
40-
40+
4141
use Symfony\Component\Validator\Constraints as Assert;
42-
42+
4343
class User
4444
{
4545
/**
4646
* @Assert\All({
4747
* @Assert\NotBlank,
48-
* @Assert\Length(min = "5")
48+
* @Assert\Length(min = 5)
4949
* })
5050
*/
5151
protected $favoriteColors = array();
@@ -77,7 +77,7 @@ entry in that array:
7777
7878
// src/Acme/UserBundle/Entity/User.php
7979
namespace Acme\UserBundle\Entity;
80-
80+
8181
use Symfony\Component\Validator\Mapping\ClassMetadata;
8282
use Symfony\Component\Validator\Constraints as Assert;
8383

‎reference/constraints/Blank.rst

Copy file name to clipboardExpand all lines: reference/constraints/Blank.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ of an ``Author`` class were blank, you could do the following:
2626

2727
.. code-block:: yaml
2828
29-
# src/BlogBundle/Resources/config/validation.yml
29+
# src/Acme/BlogBundle/Resources/config/validation.yml
3030
Acme\BlogBundle\Entity\Author:
3131
properties:
3232
firstName:

‎reference/constraints/Callback.rst

Copy file name to clipboardExpand all lines: reference/constraints/Callback.rst
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,17 @@ those errors should be attributed::
9898

9999
// ...
100100
use Symfony\Component\Validator\ExecutionContextInterface;
101-
101+
102102
class Author
103103
{
104104
// ...
105105
private $firstName;
106-
106+
107107
public function isAuthorValid(ExecutionContextInterface $context)
108108
{
109109
// somehow you have an array of "fake names"
110110
$fakeNames = array();
111-
111+
112112
// check if the name is actually a fake name
113113
if (in_array($this->getFirstName(), $fakeNames)) {
114114
$context->addViolationAt('firstname', 'This name sounds totally fake!', array(), null);
@@ -155,7 +155,7 @@ process. Each method can be one of the following formats:
155155
156156
/**
157157
* @Assert\Callback(methods={
158-
* { "Acme\BlogBundle\MyStaticValidatorClass", "isAuthorValid"}
158+
* { "Acme\BlogBundle\MyStaticValidatorClass", "isAuthorValid" }
159159
* })
160160
*/
161161
class Author
@@ -208,10 +208,10 @@ process. Each method can be one of the following formats:
208208
object being validated (e.g. ``Author``) as well as the ``ExecutionContextInterface``::
209209

210210
namespace Acme\BlogBundle;
211-
211+
212212
use Symfony\Component\Validator\ExecutionContextInterface;
213213
use Acme\BlogBundle\Entity\Author;
214-
214+
215215
class MyStaticValidatorClass
216216
{
217217
public static function isAuthorValid(Author $author, ExecutionContextInterface $context)

‎reference/constraints/Collection.rst

Copy file name to clipboardExpand all lines: reference/constraints/Collection.rst
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ blank but is no longer than 100 characters in length, you would do the following
8585
* @Assert\NotBlank(),
8686
* @Assert\Length(
8787
* max = 100,
88-
* maxMessage = "Your bio is too long!"
88+
* maxMessage = "Your short bio is too long!"
8989
* )
9090
* }
9191
* },
@@ -117,7 +117,7 @@ blank but is no longer than 100 characters in length, you would do the following
117117
<constraint name="NotBlank" />
118118
<constraint name="Length">
119119
<option name="max">100</option>
120-
<option name="maxMessage">Your bio is too long!</option>
120+
<option name="maxMessage">Your short bio is too long!</option>
121121
</constraint>
122122
</value>
123123
</option>
@@ -146,7 +146,10 @@ blank but is no longer than 100 characters in length, you would do the following
146146
'personal_email' => new Assert\Email(),
147147
'lastName' => array(
148148
new Assert\NotBlank(),
149-
new Assert\Length(array("max" => 100)),
149+
new Assert\Length(array(
150+
'max' => 100,
151+
'maxMessage' => 'Your short bio is too long!',
152+
)),
150153
),
151154
),
152155
'allowMissingFields' => true,
@@ -215,13 +218,11 @@ field is optional but must be a valid email if supplied, you can do the followin
215218
* @Assert\Collection(
216219
* fields={
217220
* "personal_email" = @Assert\Required({@Assert\NotBlank, @Assert\Email}),
218-
* "alternate_email" = @Assert\Optional(@Assert\Email),
221+
* "alternate_email" = @Assert\Optional(@Assert\Email)
219222
* }
220223
* )
221224
*/
222-
protected $profileData = array(
223-
'personal_email',
224-
);
225+
protected $profileData = array('personal_email');
225226
}
226227
227228
.. code-block:: xml

‎reference/constraints/Country.rst

Copy file name to clipboardExpand all lines: reference/constraints/Country.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Basic Usage
2020

2121
.. code-block:: yaml
2222
23-
# src/UserBundle/Resources/config/validation.yml
23+
# src/Acme/UserBundle/Resources/config/validation.yml
2424
Acme\UserBundle\Entity\User:
2525
properties:
2626
country:
@@ -36,7 +36,7 @@ Basic Usage
3636
class User
3737
{
3838
/**
39-
* @Assert\Country
39+
* @Assert\Country()
4040
*/
4141
protected $country;
4242
}

0 commit comments

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