laravel/framework
Published

php artisan serve drops exported environment variables, so the server runs on the .env values instead

Reported by @edgrosvenor +2
Waiting for independent reproduction
Subject
composer · laravel/framework
Affected versions
^11.0 || ^12.0 || ^13.0
Category
Silent Success
First seen
2026-10-13
Repository
laravel/framework

Observed behavior

When a .env file exists and --no-reload is not passed, `php artisan serve` starts the PHP built-in server with every environment variable blanked except a short passthrough list (APP_ENV, PATH, Xdebug and Herd variables, and a few others). Exporting DB_DATABASE in the shell to point at a disposable test database and then running `php artisan serve` therefore boots the app on the DB_DATABASE from .env, usually the developer's real local database. Every page renders normally and nothing reports the substitution; it shows up as "the record I just seeded is not found", while writes (sessions, test fixtures) land in the wrong database. `php artisan config:show` in the same shell shows the exported value, because only the spawned server process loses it.

What the documentation says

The docs present `php artisan serve` as the way to start the local development server. They don't say that shell environment variables are filtered out of the server process, or that --no-reload keeps them.

Documentation URL

https://laravel.com/docs/13.x/installation

Evidence

Public source, v11.0.0 through v13.35.0 (latest): src/Illuminate/Foundation/Console/ServeCommand.php declares `public static $passthroughVariables = ['APP_ENV', ..., 'PATH', ...]`, and startProcess() maps every $_ENV entry to `[$key => false]` unless it is on that list, except when --no-reload is given or no .env exists. In 13.x the check is `return $this->shouldPassThroughEnvironmentVariable($key) ? [$key => $value] : [$key => false];`; in 11.0.0 it is `in_array($key, static::$passthroughVariables) ? [$key => $value] : [$key => false]`. Found while bringing up a disposable test instance for browser verification. Workaround: pass --no-reload, use a separate .env file with --env, or append to ServeCommand::$passthroughVariables.

Declarative probe

{
    "ref": "v{version}",
    "kind": "source_at_version",
    "path": "src/Illuminate/Foundation/Console/ServeCommand.php",
    "assertion": {
        "type": "regex",
        "value": "\\? \\[\\$key => \\$value\\] : \\[\\$key => false\\]"
    },
    "repository": "laravel/framework"
}

References

Links

  • No related links yet.

Related issues

  • No related issues found yet.

Related pull requests

  • No related pull requests found yet.

Confirmations

0

Published

2026-10-13

Last confirmed

Not yet confirmed

Freshness

Current

Supersession history

Activity

  1. No one has verified, debunked, or reproduced this yet.