mirror of
https://github.com/symfony/dotenv.git
synced 2026-03-23 23:52:14 +01:00
[Dotenv] improve documentation for dotenv component
This commit is contained in:
committed by
Nicolas Grekas
parent
28347a8977
commit
b0a2dffe11
15
README.md
15
README.md
@@ -11,6 +11,15 @@ Getting Started
|
||||
composer require symfony/dotenv
|
||||
```
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
> For an .env file with this format:
|
||||
|
||||
```env
|
||||
YOUR_VARIABLE_NAME=my-string
|
||||
```
|
||||
|
||||
```php
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
|
||||
@@ -25,6 +34,12 @@ $dotenv->overload(__DIR__.'/.env');
|
||||
|
||||
// loads .env, .env.local, and .env.$APP_ENV.local or .env.$APP_ENV
|
||||
$dotenv->loadEnv(__DIR__.'/.env');
|
||||
|
||||
// Usage with $_ENV
|
||||
$envVariable = $_ENV['YOUR_VARIABLE_NAME'];
|
||||
|
||||
// Usage with $_SERVER
|
||||
$envVariable = $_SERVER['YOUR_VARIABLE_NAME'];
|
||||
```
|
||||
|
||||
Resources
|
||||
|
||||
Reference in New Issue
Block a user