Skip to content

Commit 1f8c90a

Browse files
committed
Merge branch '5.4' into 6.2
* 5.4: [Doctrine] Cleaning up the config code samples Tweak Add a trailing slash to dir names Adding backticks [ExpressionLanguage] Mention the validator.expression_language service [Configuration] Add $_ENV and $_SERVER example with .env
2 parents de2fc32 + bd0595e commit 1f8c90a

File tree

5 files changed

+40
-44
lines changed

5 files changed

+40
-44
lines changed

components/expression_language.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ Installation
1919
.. include:: /components/require_autoload.rst.inc
2020

2121
How can the Expression Engine Help Me?
22-
--------------------------------------
22+
23+
.. _how-can-the-expression-engine-help-me:
24+
25+
How can the Expression Language Help Me?
26+
----------------------------------------
2327

2428
The purpose of the component is to allow users to use expressions inside
2529
configuration for more complex logic. For some examples, the Symfony Framework

configuration.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,17 @@ This example shows how you could configure the application secret using an env v
619619
]);
620620
};
621621
622+
.. note::
623+
624+
Your env vars can also be accessed via the PHP super globals ``$_ENV`` and
625+
``$_SERVER`` (both are equivalent)::
626+
627+
$databaseUrl = $_ENV['DATABASE_URL']; // mysql://db_user:db_password@127.0.0.1:3306/db_name
628+
$env = $_SERVER['APP_ENV']; // prod
629+
630+
However, in Symfony applications there's no need to use this, because the
631+
configuration system provides a better way of working with env vars.
632+
622633
.. seealso::
623634

624635
The values of env vars can only be strings, but Symfony includes some

doctrine/multiple_entity_managers.rst

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. index::
22
single: Doctrine; Multiple entity managers
33

4-
How to Work with multiple Entity Managers and Connections
4+
How to Work with Multiple Entity Managers and Connections
55
=========================================================
66

77
You can use multiple Doctrine entity managers or connections in a Symfony
@@ -32,20 +32,12 @@ The following configuration code shows how you can configure two entity managers
3232
# config/packages/doctrine.yaml
3333
doctrine:
3434
dbal:
35-
default_connection: default
3635
connections:
3736
default:
38-
# configure these for your database server
3937
url: '%env(resolve:DATABASE_URL)%'
40-
driver: 'pdo_mysql'
41-
server_version: '5.7'
42-
charset: utf8mb4
4338
customer:
44-
# configure these for your database server
45-
url: '%env(resolve:DATABASE_CUSTOMER_URL)%'
46-
driver: 'pdo_mysql'
47-
server_version: '5.7'
48-
charset: utf8mb4
39+
url: '%env(resolve:CUSTOMER_DATABASE_URL)%'
40+
default_connection: default
4941
orm:
5042
default_entity_manager: default
5143
entity_managers:
@@ -82,20 +74,12 @@ The following configuration code shows how you can configure two entity managers
8274
8375
<doctrine:config>
8476
<doctrine:dbal default-connection="default">
85-
<!-- configure these for your database server -->
8677
<doctrine:connection name="default"
8778
url="%env(resolve:DATABASE_URL)%"
88-
driver="pdo_mysql"
89-
server_version="5.7"
90-
charset="utf8mb4"
9179
/>
9280
93-
<!-- configure these for your database server -->
9481
<doctrine:connection name="customer"
95-
url="%env(resolve:DATABASE_CUSTOMER_URL)%"
96-
driver="pdo_mysql"
97-
server_version="5.7"
98-
charset="utf8mb4"
82+
url="%env(resolve:CUSTOMER_DATABASE_URL)%"
9983
/>
10084
</doctrine:dbal>
10185
@@ -131,37 +115,28 @@ The following configuration code shows how you can configure two entity managers
131115
use Symfony\Config\DoctrineConfig;
132116
133117
return static function (DoctrineConfig $doctrine) {
134-
$doctrine->dbal()->defaultConnection('default');
135-
136-
// configure these for your database server
118+
// Connections:
137119
$doctrine->dbal()
138120
->connection('default')
139-
->url(env('DATABASE_URL')->resolve())
140-
->driver('pdo_mysql')
141-
->serverVersion('5.7')
142-
->charset('utf8mb4');
143-
144-
// configure these for your database server
121+
->url(env('DATABASE_URL')->resolve());
145122
$doctrine->dbal()
146123
->connection('customer')
147-
->url(env('DATABASE_CUSTOMER_URL')->resolve())
148-
->driver('pdo_mysql')
149-
->serverVersion('5.7')
150-
->charset('utf8mb4');
151-
124+
->url(env('CUSTOMER_DATABASE_URL')->resolve());
125+
$doctrine->dbal()->defaultConnection('default');
126+
127+
// Entity Managers:
152128
$doctrine->orm()->defaultEntityManager('default');
153-
$emDefault = $doctrine->orm()->entityManager('default');
154-
$emDefault->connection('default');
155-
$emDefault->mapping('Main')
129+
$defaultEntityManager = $doctrine->orm()->entityManager('default');
130+
$defaultEntityManager->connection('default');
131+
$defaultEntityManager->mapping('Main')
156132
->isBundle(false)
157133
->type('annotation')
158134
->dir('%kernel.project_dir%/src/Entity/Main')
159135
->prefix('App\Entity\Main')
160136
->alias('Main');
161-
162-
$emCustomer = $doctrine->orm()->entityManager('customer');
163-
$emCustomer->connection('customer');
164-
$emCustomer->mapping('Customer')
137+
$customerEntityManager = $doctrine->orm()->entityManager('customer');
138+
$customerEntityManager->connection('customer');
139+
$customerEntityManager->mapping('Customer')
165140
->isBundle(false)
166141
->type('annotation')
167142
->dir('%kernel.project_dir%/src/Entity/Customer')

reference/constraints/Expression.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ For more information about the expression and what variables are available
217217
to you, see the :ref:`expression <reference-constraint-expression-option>`
218218
option details below.
219219

220+
.. tip::
221+
222+
Internally, this expression validator constraint uses a service called
223+
``validator.expression_language`` to evaluate the expressions. You can
224+
decorate or extend that service to fit your own needs.
225+
220226
Options
221227
-------
222228

setup/web_server_configuration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ When using Apache, you can configure PHP as an
1616
:ref:`PHP FPM <web-server-apache-fpm>`. FastCGI also is the preferred way
1717
to use PHP :ref:`with Nginx <web-server-nginx>`.
1818

19-
.. sidebar:: The public directory
19+
.. sidebar:: The ``public/`` directory
2020

21-
The public directory is the home of all of your application's public and
21+
The ``public/`` directory is the home of all of your application's public and
2222
static files, including images, stylesheets and JavaScript files. It is
2323
also where the front controller (``index.php``) lives.
2424

0 commit comments

Comments
 (0)