Command: Encapsulate a request as an object, letting you parameterise methods, queue requests, log them, and support undoable operations. The Command pattern turns an action into an object. Instead of calling sendInvoice($invoice) directly, you create a SendInvoice object that holds everything needed to perform the action later. That opens up useful possibilities. Commands can be queued, logged, retried, scheduled or undone. A text editor stores each edit as a command, so it can undo them in reverse order.
Laravel's queued jobs are command objects. A GenerateReport job carries its data, goes onto a queue and is executed by a worker, possibly on another server. Artisan console commands follow the same idea. Keep commands small and serialisable, and make them safe to run twice. A job that runs again after a timeout should not send the same email twice.
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.
'Cloud design patterns for distributed systems architecture covering 42 industry-standard patterns across reliability, performance, messaging, security, and deployment categories. Use when designing, reviewing, or implementing distributed system architectures.'