Skip to content

Dotenv loader#354

Merged
freost merged 8 commits into
masterfrom
dotenv
Jul 25, 2026
Merged

Dotenv loader#354
freost merged 8 commits into
masterfrom
dotenv

Conversation

@freost

@freost freost commented Jul 24, 2026

Copy link
Copy Markdown
Member

Type


Yes/No
Bugfix? -
New feature? Yes
Other? -

Additional information

Yes/No
Has backwards compatibility breaks? No
Has unit and/or integration tests? Yes

Description


Add a simple and fast dotenv loader. The loader can interpolate variables but does not do so by default. It will also not override existing values unless configured to do so.

(new DotenvLoader)->load('/path/to/.env')

@freost freost changed the title WIP Dotenv loader Jul 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new mako\env\DotenvLoader to load .env files into the runtime environment with optional variable interpolation and optional overriding of existing variables, along with unit tests and fixture .env files to validate parsing and error handling.

Changes:

  • Added DotenvLoader implementation and new EnvException type under mako\env.
  • Added unit tests plus fixture .env files covering valid parsing, overrides, interpolation, and parse errors.
  • Documented the addition in CHANGELOG.md.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/unit/env/fixtures/unterminated-single-quote.env Fixture for unterminated single-quoted value error handling.
tests/unit/env/fixtures/unterminated-double-quote.env Fixture for unterminated double-quoted value error handling.
tests/unit/env/fixtures/undefined-variable.env Fixture for undefined ${VAR} interpolation error handling.
tests/unit/env/fixtures/override.env Fixture for duplicate key behavior with/without override enabled.
tests/unit/env/fixtures/invalid-key.env Fixture for invalid key validation.
tests/unit/env/fixtures/invalid-declaration.env Fixture for invalid declaration (missing =) validation.
tests/unit/env/fixtures/basic.env Fixture covering whitespace, quotes, comments, escaping, and interpolation scenarios.
tests/unit/env/DotenvLoaderTest.php Unit tests validating loader behavior and expected exceptions/messages.
src/mako/env/exceptions/EnvException.php New exception type for dotenv/env parsing/loading errors.
src/mako/env/DotenvLoader.php New dotenv loader implementation (parsing, interpolation, override/putenv options).
CHANGELOG.md Notes the new dotenv loader feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/mako/env/DotenvLoader.php Outdated
Comment thread src/mako/env/DotenvLoader.php Outdated
Comment thread src/mako/env/DotenvLoader.php
Comment thread src/mako/env/DotenvLoader.php
@freost
freost marked this pull request as ready for review July 25, 2026 20:40
@freost
freost merged commit 816912d into master Jul 25, 2026
6 checks passed
@freost
freost deleted the dotenv branch July 25, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants