Ehsan Bagherzadegan

Writing

Notes on senior PHP engineering, maintainable backend systems, Laravel, Symfony, Filament, Livewire, and practical business software.

Filtered by Architecture Clear filter
15 min read

Action Pattern in PHP and Laravel

The **Action Pattern** in PHP and Laravel is a clean architectural approach where each important business operation is placed inside its own dedicated class. Instead of putting application logic directly inside controllers, models, jobs, or services, an Action class represents one specific use case, such as `CreateUserAction`, `SendInvoiceAction`, or `CancelSubscriptionAction`. This pattern helps keep controllers thin, improves reusability, and makes business logic easier to test. A controller should handle HTTP concerns, while an Action should handle what the application actually needs to do. In Laravel, Actions work naturally with dependency injection, Form Requests, Jobs, Commands, and Livewire components. For senior PHP developers, the main benefit of the Action Pattern is not simply reducing code, but creating clearer ownership of business operations. Each Action gives a meaningful name to a use case and keeps the application easier to maintain as it grows.