Skip to content

Commit c7d7543

Browse files
minor #60570 [Dotenv] improve documentation for dotenv component (crydotsnake)
This PR was squashed before being merged into the 7.4 branch. Discussion ---------- [Dotenv] improve documentation for dotenv component | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Improves the documentation for the Symfony dotenv component :) Commits ------- adfc7e9 [Dotenv] improve documentation for dotenv component
2 parents d92477a + adfc7e9 commit c7d7543

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)