dkm/dotenv-autoload
Composer 安装命令:
composer require dkm/dotenv-autoload
包简介
Auto-loads .env then .env.local at Composer autoload time. No plugin, no config.
README 文档
README
Auto-loads .env then .env.local into the environment at Composer autoload
time. It replaces helhum/dotenv-connector + a custom adapter package with a
single plain library — no Composer plugin, no extra config, no
allow-plugins entry, no generated include file.
Install
composer require dkm/dotenv-autoload
That's the whole integration. The package's autoload.files entry runs
src/load.php whenever vendor/autoload.php is loaded.
Behaviour
- Loads
<project-root>/.env, then<project-root>/.env.local..envholds shared defaults;.env.localcarries per-instance overrides. - Project root is resolved via
Composer\InstalledVersions::getRootPackage(), so it works even when this package is installed as a symlinked path repo (wheredirname(__DIR__, N)would point intopackages/...). - Uses Symfony Dotenv
load(): a variable already set in the real environment (or in.env) is not overwritten by.env.local. SetDOTENV_OVERRIDE=1to switch tooverload()so.env.localwins. - Skips entirely when
APP_ENVis already set in the environment.
Boundary (important)
Env vars are exposed when vendor/autoload.php is loaded — i.e. on web requests
and in CLI subprocesses (e.g. the typo3 binary invoked from Composer
scripts). They are not exposed inline inside the running Composer process.
So this is safe for:
- application runtime, and
- Composer scripts that shell out to a binary (
typo3 ...).
It is not sufficient for:
- a Composer plugin, or
- an inline PHP-callback Composer script (
"Vendor\\Class::method"),
that reads these env vars during composer install/update. If you ever add one
of those and it needs .env values, keep helhum/dotenv-connector for that
project instead.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-06-23