imanghafoori/laravel-decorator
Laravel Decorator lets you wrap method calls on any class with custom decorators, adding caching, logging, retries, or auth checks without editing the original code. Register a decorator once and every call to that class flows through it.
Architecture fit
Class@method string with cross-cutting behavior (caching/memoization, conditional execution, fallback values on failure) without changing the decorated class's signature.decorate() helper, which is convenient but sits outside the container's control and is invisible to static analysis.Integration feasibility
composer require + package discovery), no schema changes, no required config publication, no migration. A working proof-of-concept is a half-day of engineering including review.decorate() will be sprinkled inconsistently alongside Cache::remember and hand-written decorator classes.Technical risk
'App\Services\Foo@bar' string targets are opaque to IDEs and to Larastan. Renaming bar will not update the string; failures surface at runtime, not at build time.Key questions
Stack fit
Cache::remember and with framework-level HTTP/cache middleware. The adoption decision is therefore as much about standardizing on one idiom as about capability.Migration path
decorate() wrapper restores the original behavior exactly.Compatibility
composer.json and add it to the dependency-review/audit gate.refreshApplication.Sequencing
decorate() vs. an injected decorator class vs. Cache::remember, plus a mandatory rule that every fallback logs.Maintenance
composer audit coverage suffices.Support
Scaling
Failure modes
| Failure | Impact | Mitigation |
|---|---|---|
| Cache-key collision from poor argument serialization | Silent wrong data returned to users | Source review before adoption; integration test with object arguments |
| Fallback swallows exceptions | Outages invisible until users report | Mandate logging/metrics on every fallback path |
| Static decorator state leaks across tests | Flaky CI, eroding trust in the suite | Verify reset behavior; add isolation test |
| Memoized state grows in Octane/queue workers | Gradual memory exhaustion | Confirm reset hook; add worker restart policy |
Renamed method breaks Class@method string |
Runtime failure after an unrelated refactor | Prefer closure targets; assert decorated targets exist at boot |
| Package abandoned | Blocks future Laravel upgrade | Vendor/fork, or wrap behind internal interface |
Convention sprawl vs. Cache::remember |
Two idioms for the same problem | Style guide + code review enforcement |
Ramp-up
Recommendation: Conditional adopt. The package solves a real, narrow problem with low integration cost and low rollback cost, which justifies a pilot. The 139 stars, single maintainer, and zero dependents mean it should never become load-bearing infrastructure — vendor it or wrap it, assign an internal owner, and gate adoption on verified cache-key semantics and long-running-process behavior.
How can I help you explore Laravel packages today?