Skip to content

Commit cd192a5

Browse files
committed
minor #17735 [Config] [Configuration] Add $_ENV and $_SERVER example with .env (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [Config] [Configuration] Add `$_ENV` and `$_SERVER` example with .env Fixes #17693 Commits ------- f300e84 [Configuration] Add $_ENV and $_SERVER example with .env
2 parents 7870c1d + f300e84 commit cd192a5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

configuration.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,12 @@ This example shows how you could configure the application secret using an env v
646646
]);
647647
};
648648
649+
Your env vars may also be accessed in your code thanks to PHP super
650+
globals ``$_ENV`` and ``$_SERVER``. Both are equivalent::
651+
652+
$databaseUrl = $_ENV['DATABASE_URL']; // mysql://db_user:db_password@127.0.0.1:3306/db_name
653+
$env = $_SERVER['APP_ENV']; // prod
654+
649655
.. versionadded:: 5.3
650656

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

0 commit comments

Comments
 (0)