maxis/laravel-eloquent-guard
Adds a lightweight guard layer to Laravel Eloquent models, helping protect sensitive attributes and control which fields can be mass-assigned or updated. Simple to configure and drop into existing models for safer, more predictable data handling.
Architecture fit
The package targets a narrow, well-understood seam in the Laravel request lifecycle: the query execution path. A runtime N+1 and slow-query detector is architecturally low-risk in principle, since it should attach via the framework's existing DB::listen / query-executed events and an optional service provider, rather than requiring changes to application domain code. That is the right shape for a TPM to want — observability bolted onto the container, not woven into business logic.
The material concern is differentiation, not feasibility. Laravel ships Model::preventLazyLoading() (Laravel 8+) and preventSilentlyDiscardingAttributes, plus DB::listen and the query log for slow-statement capture. Laravel Telescope and Debugbar cover the developer-facing view of the same signal. A TPM's first question must therefore be: what does this package do that three lines in AppServiceProvider::boot() do not? Plausible answers — request-scoped aggregation, deduplication of N+1 patterns across a request, threshold configuration, production-safe sampling, structured log/alert output — are all defensible, but none are verifiable from the description alone. The package name ("eloquent-guard") also reads as model-integrity tooling rather than a performance monitor, which hints at either a repositioned project or stale metadata.
Integration feasibility
Low integration cost in the happy path: Composer install, provider auto-discovery, publish a config file, set thresholds. No schema changes, no queue workers, no external services implied. This is a same-sprint evaluation for one engineer.
Technical risk
Key questions
DB::listen, a middleware, or something more invasive — and what is the measured per-query overhead at p50/p99?preventLazyLoading() plus a slow-query log, in one sentence?Stack fit
Fits any Laravel application on a supported version; no assumptions about database engine, cache, or hosting. The natural deployment targets are staging and pre-production, where query patterns are representative and overhead is tolerable. Production enablement should be opt-in and sampled.
Migration path
None required — this is additive instrumentation, reversible by removing the provider. That is its strongest procurement argument: the cost of being wrong is a config flag, not a rollback.
Compatibility
Verify against the exact Laravel and PHP versions in the estate before anything else. Query-event internals are stable but not frozen. Also confirm interaction with existing instrumentation — Telescope and Debugbar already wrap query execution, and stacking three listeners on the same event is a known source of double-counting and inflated overhead.
Sequencing
preventLazyLoading() in a non-production environment for one iteration and diff the findings. If the native approach surfaces the same N+1s, close the evaluation.Maintenance
Assume you will maintain it. Zero dependents means no community pressure to keep it current with framework releases. Assign a named owner and add a dependency-review entry so upgrades of Laravel trigger an explicit re-validation. A vendored fork should be a pre-approved option, not an emergency measure.
Support
No commercial support; issue tracker responsiveness is unverified and should be tested with a trivial question before it matters. Internal support burden is low while it works and total if it breaks during an incident, since failure modes are on the request path.
Scaling
Overhead scales with query volume, which is exactly where the application is already under stress — the tool is most expensive precisely when you need it most. Sampling and per-request query caps are non-negotiable at scale. Log volume is the second-order cost: a naive implementation on a chatty endpoint can multiply logging spend.
Failure modes
Ramp-up
Effectively zero for developers — there is no new API to learn, only output to read. The real ramp-up is organizational: agreeing on thresholds, defining suppression conventions for intentional loops, and deciding who triages the findings. That is a half-day of team time and is the same cost regardless of whether you adopt this package or the native alternative.
Recommendation posture: proceed to a time-boxed spike, framed as a bake-off against framework-native tooling. The integration cost is low enough to justify the experiment, and the adoption and maintenance signals are weak enough that adoption without a head-to-head comparison would be unjustified.
How can I help you explore Laravel packages today?