Skip to content

Commit f300e84

Browse files
[Configuration] Add $_ENV and $_SERVER example with .env
1 parent 138546c commit f300e84

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

configuration.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Configuration Formats
5858
~~~~~~~~~~~~~~~~~~~~~
5959

6060
Unlike other frameworks, Symfony doesn't impose a specific format on you to
61-
configure your applications, but lets you choose between YAML, XML and PHP.
61+
configure your applications, but lets you choose between YAML, XML and PHP.
6262
Throughout the Symfony documentation, all configuration examples will be
6363
shown in these three formats.
6464

@@ -653,6 +653,12 @@ This example shows how you could configure the database connection using an env
653653
]);
654654
};
655655
656+
Your env vars may also be accessed in your code thanks to PHP super
657+
globals ``$_ENV`` and ``$_SERVER``. Both are equivalent::
658+
659+
$databaseUrl = $_ENV['DATABASE_URL']; // mysql://db_user:db_password@127.0.0.1:3306/db_name
660+
$env = $_SERVER['APP_ENV']; // prod
661+
656662
.. versionadded:: 5.3
657663

658664
The ``env()`` configurator syntax was introduced in 5.3.

0 commit comments

Comments
 (0)