Symfony Dotenv

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

Library
Composer
vv8.1.2
3,788stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
78/100Good
Development Activity72
Maintenance80
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture74
Code Quality80
Innovation60
Learning Curve88

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

754

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

View details
47
Repo Health
66
Technical
66
Dependency
Built with
PHP63%
Vue18%
Gherkin13%
Updated 2 months ago
PHP
63%
AGPL 3.0

Hyvor Relay

Devops · AI Development · Monitoring

819

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
69
Repo Health
79
Technical
70
Dependency
Built with
PHP63%
Svelte23%
Go12%
Updated today
PHP
86%
AGPL 3.0

Kimai

Invoicing Finance · Project Management

4,918

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
63
Dependency
Built with
PHP86%
Updated today
PHP
48%
AGPL 3.0

Leantime

Productivity · Project Management · Collaboration

11,391

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

View details
90
Repo Health
68
Technical
67
Dependency
Built with
PHP48%
CSS20%
Blade17%
Updated 4 days ago
PHP
82%
Other

Mautic

Automation · Marketing · Ecommerce

10,366

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

View details
98
Repo Health
76
Technical
64
Dependency
Built with
PHP82%
Updated yesterday
PHP
84%
MIT

wallabag

Bookmarks Archiving

12,917

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
92
Repo Health
81
Technical
59
Dependency
Built with
PHP84%
Twig13%
Updated yesterday

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

Search