Decorator: Attach additional responsibilities to an object dynamically — a flexible alternative to subclassing for extending behaviour. The Decorator pattern adds behaviour to an object by wrapping it in another object with the same interface. The wrapper does its extra work and passes the call through to the original. A classic example is caching. A CachedProductRepository wraps the normal ProductRepository. It checks the cache first and only asks the real repository when the value is missing. The rest of the application does not notice the difference.
Decorators can be stacked: logging around caching around the real implementation. That avoids deep inheritance trees where every combination needs its own subclass. In Laravel, you can bind a decorated class in the service container, so the change happens in one place. Keep each decorator focused on one concern, so the stack stays easy to follow.
Apply Spatie's Laravel and PHP coding standards for any task that creates, edits, reviews, refactors, or formats Laravel/PHP code or Blade templates; use for controllers, Eloquent models, routes, config, validation, migrations, tests, and related files to align with Laravel conventions and PSR-12.
Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.