sixlive/dotenv-editor
sixlive/dotenv-editor is a PHP package for reading and editing .env files programmatically. Update, add, or delete individual environment variables while preserving comments, whitespace, and file structure—ideal for Laravel apps and tooling that needs safe, targeted .env changes.
.env values (mail credentials, APP_URL, third-party API keys, feature toggles) without SSH or server access. This is the primary justification for adoption — it replaces a bespoke parser/writer with a small, MIT-licensed dependency..env writes with comment preservation make generated files human-readable and support-friendly..env files. That is an architectural decision (database-backed settings, encrypted config stores) and this package should not be used to defer it.Consider it when:
.env file at runtime (single-tenant, self-hosted, VM/bare-metal deployments)..env files and generate support incidents..env before modifying it) rather than building atomic write-and-rollback logic yourself.Look elsewhere when:
.env is global to the process; per-tenant settings belong in the database or a config service..env is plaintext on disk. If you need encryption at rest, rotation, or audit logs, you need Vault, AWS Secrets Manager, or an encrypted settings table — not a file editor..env have no effect until config:cache/config:clear runs. If you cannot trigger that reliably from the write path, the feature will appear broken.Diligence items before committing: confirm the maintenance cadence and bus factor (74 stars, likely a small maintainer pool), pin the version, and wrap all calls behind your own thin service class so the dependency is swappable. Add a test that asserts the app still boots after an edit.
For executives: This is a small, free, MIT-licensed utility that lets our application change its own environment configuration file safely, preserving comments and taking a backup before each write. It removes roughly the equivalent of a few engineering days of custom file-parsing code and eliminates a class of "our deploy script corrupted the .env file" outages. It is a building block, not a product; it unlocks self-service configuration and setup-wizard work already on the roadmap.
For engineering: Adopt behind a narrow internal interface. The package exposes load/get/set/add/delete plus save, with comment-preserving output and backup support, and ships a Laravel service provider and facade. Two hard constraints to design around: (1) production config caching must be cleared after any write, so the save path needs to invoke config:clear or invalidate the cache in the same operation; and (2) it is filesystem- and single-node-scoped — do not use it for per-tenant settings, containers, or anything requiring encrypted secrets. Treat .env mutation as an administrative capability: gate it behind authorization, log who changed what, and validate values before write. Pin the version and keep the wrapper thin so we can replace it in an afternoon if maintenance lapses.
How can I help you explore Laravel packages today?