Skip to content

Commit adfc7e9

Browse files
crydotsnakenicolas-grekas
authored andcommitted
[Dotenv] improve documentation for dotenv component
1 parent 5e1f34e commit adfc7e9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Symfony/Component/Dotenv/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ Getting Started
1111
composer require symfony/dotenv
1212
```
1313

14+
Usage
15+
-----
16+
17+
> For an .env file with this format:
18+
19+
```env
20+
YOUR_VARIABLE_NAME=my-string
21+
```
22+
1423
```php
1524
use Symfony\Component\Dotenv\Dotenv;
1625

@@ -25,6 +34,12 @@ $dotenv->overload(__DIR__.'/.env');
2534

2635
// loads .env, .env.local, and .env.$APP_ENV.local or .env.$APP_ENV
2736
$dotenv->loadEnv(__DIR__.'/.env');
37+
38+
// Usage with $_ENV
39+
$envVariable = $_ENV['YOUR_VARIABLE_NAME'];
40+
41+
// Usage with $_SERVER
42+
$envVariable = $_SERVER['YOUR_VARIABLE_NAME'];
2843
```
2944

3045
Resources

0 commit comments

Comments
 (0)