Symfony Dotenv

Parses .env files and registers their values as environment variables for PHP applications

Library
Composer
vv8.1.6
3,788 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
73 /100 Good
Development Activity 60
Maintenance 72
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
76 /100 Good
Architecture 74
Code Quality 80
Innovation 60
Learning Curve 88

Symfony Dotenv parses .env files and populates PHP’s environment (via putenv, $_ENV, and $_SERVER) so applications can configure themselves from plain environment variables in development, without needing them set at the OS or web-server level. It supports variable interpolation, .env file overrides per environment (.env.local, .env.test), and includes a debug command for inspecting resolved values, and works standalone or as the environment layer inside a full Symfony application.

What You Get

  • A Dotenv class that loads one or more .env files and populates $_ENV/$_SERVER/putenv()
  • Support for the standard Symfony env-file override cascade (.env, .env.local, .env.$APP_ENV, .env.$APP_ENV.local)
  • Variable interpolation (${OTHER_VAR}) and default-value syntax within .env files
  • A DebugCommand and DotenvDumpCommand console command for inspecting which env vars are resolved and from which file
  • Clear exception types (FormatException, PathException, VariableCircularReferenceException) for malformed or missing .env files

Common Use Cases

  • Loading local development configuration (database URLs, API keys, debug flags) from a .env file instead of hardcoding or exporting shell variables
  • Layering environment-specific overrides (.env.local, .env.test) on top of a checked-in base .env file
  • Debugging which value an environment variable actually resolved to and from which file, via the bundled console command
  • Using dotenv parsing standalone in non-Symfony PHP scripts or micro-frameworks that want the same .env convention

Under The Hood

Architecture — The component centers on a single Dotenv.php class that tokenizes and parses .env file contents (handling quoting, comments, interpolation, and export-style prefixes) and writes resolved values into PHP’s superglobals and process environment; Command/ layers optional Symfony Console commands (DebugCommand, DotenvDumpCommand) on top for introspection, and Exception/ defines a small hierarchy of typed parse/path errors. Tech Stack — Pure PHP (100% of the codebase), requiring PHP 8.4.1+, with symfony/console and symfony/process only as optional dev/require-dev dependencies for the CLI commands — the core parser has zero required dependencies. Code Quality — A dedicated Tests/ directory covers the parser and commands; the component ships explicit, typed exceptions (rather than generic RuntimeException) for format errors, missing paths, and circular variable references, which makes failure modes easy to catch and handle precisely. API Design — The primary entry point is a single method call ((new Dotenv())->load(...) or bootEnv(...)), matching the near-zero-config convention users expect from dotenv libraries across ecosystems; the override cascade (.env.local, .env.$APP_ENV) is opt-in and automatic once file naming conventions are followed.

Used by 6 apps in this directory

PHP
63%
Other

BillaBear

Ecommerce · Invoicing Finance

761

Self-hostable subscription management and billing platform with Stripe integration, tax automation, configurable workflows, and Twig-based document generation.

View details
76
Repo Health
66
Technical
65
Dependency
Built with
PHP 63%
Vue 18%
Gherkin 13%
Updated 2 weeks ago
PHP
63%
AGPL 3.0

Hyvor Relay

AI Development · Devops · Monitoring

908

Self-hosted, open-source email API that automates DNS, manages SMTP delivery, and provides deep observability — replacing SES, Mailgun, and SendGrid with infrastructure you fully own.

View details
68
Repo Health
79
Technical
70
Dependency
Built with
PHP 63%
Svelte 23%
Go 11%
Updated 1 weeks ago
PHP
86%
AGPL 3.0

Kimai

Invoicing Finance · Project Management

5,046

Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.

View details
94
Repo Health
78
Technical
64
Dependency
Built with
PHP 86%
Updated 4 days ago
PHP
48%
AGPL 3.0

Leantime

Collaboration · Productivity · Project Management

11,672

Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira

View details
90
Repo Health
68
Technical
65
Dependency
Built with
PHP 48%
CSS 20%
Blade 17%
Updated 1 weeks ago
PHP
82%
Other

Mautic

Automation · Ecommerce · Marketing

10,570

The world's largest open source marketing automation platform — own your data, run multi-channel campaigns, and escape vendor lock-in forever.

View details
97
Repo Health
76
Technical
63
Dependency
Built with
PHP 82%
Updated 1 weeks ago
PHP
84%
MIT

wallabag

Bookmarks Archiving

12,989

Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.

View details
93
Repo Health
81
Technical
59
Dependency
Built with
PHP 84%
Twig 13%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers