8000 Merge branch '5.2' into 5.x · symfony/symfony-docs@c2775b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit c2775b3

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: [Validator] Removing the recommended `Constraints` subdirectory Add a note about exposing env vars for unrecognized Docker services
2 parents d41389a + 9d71f15 commit c2775b3

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

setup/symfony_server.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ project. It understands that this is a MySQL service and creates environment
299299
variables accordingly with the service name (``database``) as a prefix:
300300
``DATABASE_URL``, ``DATABASE_HOST``, ...
301301

302+
If the service is not in the supported list below, generic environment
303+
variables are set: ``PORT``, ``IP``, and ``HOST``.
304+
302305
If the ``docker-compose.yaml`` names do not match Symfony's conventions, add a
303306
label to override the environment variables prefix:
304307

@@ -361,6 +364,20 @@ When Docker services are running, browse a page of your Symfony application and
361364
check the "Symfony Server" section in the web debug toolbar; you'll see that
362365
"Docker Compose" is "Up".
363366

367+
.. note::
368+
369+
If you don't want environment variables to be exposed for a service, set
370+
the ``com.symfony.server.service-ignore`` label to ``true``:
371+
372+
.. code-block:: yaml
373+
374+
# docker-compose.yaml
375+
services:
376+
db:
377+
ports: [3306]
378+
labels:
379+
com.symfony.server.service-ignore: true
380+
364381
If your Docker Compose file is not at the root of the project, use the
365382
``COMPOSE_FILE`` and ``COMPOSE_PROJECT_NAME`` environment variables to define
366383
its location, same as for ``docker-compose``:

validation/custom_constraint.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Creating the Constraint Class
1414

1515
First you need to create a Constraint class and extend :class:`Symfony\\Component\\Validator\\Constraint`::
1616

17-
// src/Validator/Constraints/ContainsAlphanumeric.php
18-
namespace App\Validator\Constraints;
17+
// src/Validator/ContainsAlphanumeric.php
18+
namespace App\Validator;
1919

2020
use Symfony\Component\Validator\Constraint;
2121

@@ -54,8 +54,8 @@ when actually performing the validation.
5454

5555
The validator class only has one required method ``validate()``::
5656

57-
// src/Validator/Constraints/ContainsAlphanumericValidator.php
58-
namespace App\Validator\Constraints;
57+
// src/Validator/ContainsAlphanumericValidator.php
58+
namespace App\Validator;
5959

6060
use Symfony\Component\Validator\Constraint;
6161
use Symfony\Component\Validator\ConstraintValidator;
@@ -71,7 +71,7 @@ The validator class only has one required method ``validate()``::
7171
}
7272

7373
// custom constraints should ignore null and empty values to allow
74-
// other constraints (NotBlank, NotNull, etc.) take care of that
74+
// other constraints (NotBlank, NotNull, etc.) to take care of that
7575
if (null === $value || '' === $value) {
7676
return;
7777
}
@@ -112,7 +112,7 @@ You can use custom validators like the ones provided by Symfony itself:
112112
// src/Entity/AcmeEntity.php
113113
namespace App\Entity;
114114
115-
use App\Validator\Constraints as AcmeAssert;
115+
use App\Validator as AcmeAssert;
116116
use Symfony\Component\Validator\Constraints as Assert;
117117
118118
class AcmeEntity
@@ -135,7 +135,7 @@ You can use custom validators like the ones provided by Symfony itself:
135135
properties:
136136
name:
137137
- NotBlank: ~
138-
- App\Validator\Constraints\ContainsAlphanumeric: ~
138+
- App\Validator\ContainsAlphanumeric: ~
139139
140140
.. code-block:: xml
141141
@@ -148,7 +148,7 @@ You can use custom validators like the ones provided by Symfony itself:
148148
<class name="App\Entity\AcmeEntity">
149149
<property name="name">
150150
<constraint name="NotBlank"/>
151-
<constraint name="App\Validator\Constraints\ContainsAlphanumeric"/>
151+
<constraint name="App\Validator\ContainsAlphanumeric"/>
152152
</property>
153153
</class>
154154
</constraint-mapping>
@@ -158,7 +158,7 @@ You can use custom validators like the ones provided by Symfony itself:
158158
// src/Entity/AcmeEntity.php
159159
namespace App\Entity;
160160
161-
use App\Validator\Constraints\ContainsAlphanumeric;
161+
use App\Validator\ContainsAlphanumeric;
162162
use Symfony\Component\Validator\Constraints\NotBlank;
163163
use Symfony\Component\Validator\Mapping\ClassMetadata;
164164
@@ -246,21 +246,21 @@ not to the property:
246246
# config/validator/validation.yaml
247247
App\Entity\AcmeEntity:
248248
constraints:
249-
- App\Validator\Constraints\ProtocolClass: ~
249+
- App\Validator\ProtocolClass: ~
250250
251251
.. code-block:: xml
252252
253253
<!-- config/validator/validation.xml -->
254254
<class name="App\Entity\AcmeEntity">
255-
<constraint name="App\Validator\Constraints\ProtocolClass"/>
255+
<constraint name="App\Validator\ProtocolClass"/>
256256
</class>
257257
258258
.. code-block:: php
259259
260260
// src/Entity/AcmeEntity.php
261261
namespace App\Entity;
262262
263-
use App\Validator\Constraints\ProtocolClass;
263+
use App\Validator\ProtocolClass;
264264
use Symfony\Component\Validator\Mapping\ClassMetadata;
265265
266266
class AcmeEntity

0 commit comments

Comments
 (0)
0