Skip to content

[Config] [Configuration] Add $_ENV and $_SERVER example with .env #17735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Configuration Formats
~~~~~~~~~~~~~~~~~~~~~

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

Expand Down Expand Up @@ -653,6 +653,12 @@ This example shows how you could configure the database connection using an env
]);
};

Your env vars may also be accessed in your code thanks to PHP super
globals ``$_ENV`` and ``$_SERVER``. Both are equivalent::

$databaseUrl = $_ENV['DATABASE_URL']; // mysql://db_user:db_password@127.0.0.1:3306/db_name
$env = $_SERVER['APP_ENV']; // prod

.. versionadded:: 5.3

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