8000 [Dotenv] improve documentation for dotenv component by crydotsnake · Pull Request #60570 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Dotenv] improve documentation for dotenv component #60570

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
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
[Dotenv] improve documentation for dotenv component
  • Loading branch information
crydotsnake authored and nicolas-grekas committed May 30, 2025
commit adfc7e97bcc8ee9f63de095aabb1af2e896ca16f
15 changes: 15 additions & 0 deletions src/Symfony/Component/Dotenv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
Loading
0