daftspunk/laravel-config-writer
A Laravel package for writing configuration files at runtime. Update config values programmatically and persist them back to your config files with a simple API, so you can manage dynamic settings without editing PHP files by hand. Handy for admin panels and settings screens.
Architecture fit. A narrow, single-responsibility library that sits at Laravel's configuration layer: a service provider, a facade, and a file-writer that parses a config/*.php file, mutates an array value, and rewrites the file while attempting to preserve comments and formatting. It is an administrative/setup-time tool (installer wizards, admin settings screens, provisioning scripts), not a request-path dependency. That makes it architecturally low-coupling: it can be introduced into any Laravel app without touching domain code, and removed with equal ease.
Integration feasibility. Low effort to install (composer require, auto-discovery, optional config publish) and a small public API surface (write($key, $value), dot-notation keys). The real feasibility constraint is environmental, not code: the package requires local, writable, on-disk config files. It is fundamentally incompatible with read-only container images, ephemeral filesystems, immutable infrastructure, and env-var-driven 12-factor deployments. It also does not participate in config:cache — writes land on disk and are invisible to a booted app until the cache is rebuilt.
Technical risk.
env() calls, closures, concatenation, heredocs, computed values, numeric keys) can produce malformed PHP or silently drop expressions.config/app.php or config/database.php is a hard boot failure — total outage, not a degraded feature.Key questions.
env() references, closures, and nested/numeric arrays — preserve, evaluate, or destroy?Stack fit. Good fit for a traditional Laravel 8–10 monolith with file-based config, a persistent writable volume, and an existing admin panel that needs to persist a handful of settings. Poor fit for stateless, containerized, horizontally scaled, or GitOps-driven deployments — there, a database- or cache-backed settings store is the correct pattern, and this package should be rejected on architectural grounds regardless of code quality.
Migration path. Adopt behind an internal seam: define a SettingsRepository interface with a ConfigFileSettings implementation backed by this package and a DatabaseSettings implementation as the fallback. Nothing else in the codebase references the package directly, so swapping it later is a one-class change. Pilot on a single low-risk config file (e.g. a custom config/branding.php) in staging before touching anything boot-critical.
Compatibility. Verify Composer constraints against the pinned framework and PHP versions; run the existing test suite plus a new round-trip fidelity test suite that writes and re-reads every config/*.php file in the repo and asserts semantic equality. Explicitly test the config:cache → write → config:cache cycle, and confirm behavior under PHP 8.2/8.3 deprecation reporting.
Sequencing.
Maintenance. Single maintainer, last release ~2 years ago, 176 stars. Assume low ongoing upstream velocity and plan to vendor or fork. Mitigating factor: the codebase is small and the problem is well-bounded, so in-house ownership is realistic — budget roughly a few engineer-days per year, mostly for framework-version compatibility.
Support. Documentation is a README-level API reference; there is no commercial support and a thin community. Institutional knowledge will live with whichever engineer integrates it, so require an internal runbook covering the write path, permissions, backup/restore of config files, and cache-rebuild steps.
Scaling. Writes are synchronous disk I/O and inherently single-node: on a multi-server fleet, each node holds a divergent config file and there is no replication. Acceptable only for infrequent, low-volume, admin-initiated changes on a single-writer topology (or shared storage). Under no circumstances should this sit behind a high-traffic or multi-tenant write path. If write frequency exceeds a handful per day, the design is wrong.
Failure modes. (1) Malformed output → application fails to boot on next request; highest severity, lowest detectability until deploy. (2) Partial write / power loss → truncated config. (3) Concurrent writes → lost update or interleaved garbage. (4) Permission or disk-full errors → write appears to succeed from the UI while nothing persisted. (5) Config-cache desync → operator sees stale behavior and re-saves, compounding the problem. (6) Injection via unvalidated values. Each needs an explicit mitigation: atomic write, file lock, backup-before-write, post-write lint (php -l), and a health check that re-boots the config.
Ramp-up. Trivial for a mid-level Laravel developer — under a day to productive use, because the API is two methods. The actual cost is not learning the package; it is building the guardrails (authorization, allow-listing, backups, validation, rollback) and the operational policy around mutating production configuration at runtime. Estimate 3–5 engineer-days end-to-end including tests and runbook, plus a standing decision on whether the pattern itself is acceptable in our deployment model.
How can I help you explore Laravel packages today?