mirazmac/dotenvwriter
Mirazmac DotenvWriter is a PHP package for safely writing and updating .env files programmatically. Set, change, or delete environment variables while preserving comments and formatting—ideal for installers, admin panels, and CLI tools modifying Laravel or PHP app config.
.env without requiring SSH access or a redeploy. That directly gates whether "admin can change configuration without engineering" is a shippable feature or a permanent backlog item..env correctly is deceptively expensive: quoting, escaping, preserving comments and ordering, handling multiline values, and avoiding file corruption. A focused MIT-licensed library is almost always cheaper than owning and testing a bespoke parser/writer..env edit currently routed through engineering is a ticket with a queue time. Automating those edits converts recurring engineering interrupts into a product capability — measurable in hours saved per month.artisan-style config commands, per-tenant environment generation for multi-tenant deployments, migration off legacy config files, and test fixtures that need realistic env state.Adopt when most of the following are true:
.env is genuinely the source of truth for configuration, and values change at install time, deploy time, or low frequency (days/weeks, not requests).vlucas/phpdotenv and Laravel's env()..env sits outside the webroot.Look elsewhere when:
.env on one instance does nothing for the other nine; ephemeral containers discard it on restart. Use database-backed settings, a config service, or a secrets manager (Vault, AWS Secrets Manager, Doppler).config:cache is in play and you need changes to take effect immediately — a written .env is invisible until the cache is cleared. Any "live settings" feature needs a database or cache-backed store, not a file.To executives: This is a small, MIT-licensed library that lets the application configure itself — it removes the "call engineering to change the mail password" class of support ticket and unblocks self-serve onboarding and installer experiences. Cost is effectively zero, the blast radius is limited to configuration file writes, and it is reversible: we can swap the implementation without touching product surfaces if we wrap it behind our own interface.
To engineering: It replaces ad hoc regex and string-splicing of .env with a maintained writer that handles escaping and quoting. Caveats we should own, not ignore: ~21 stars and a single maintainer means we pin the version, vendor or lock it, and keep it behind an internal ConfigWriter contract; we add atomic write, backup-before-write, a file-permission check, and coverage for multiline and special-character values. It is not a configuration-management strategy — it is appropriate only for filesystem-local env values at install/deploy time, and it must be paired with an explicit config:clear step or excluded from the live-settings path entirely.
How can I help you explore Laravel packages today?