lorisleiva/laravel-actions
Organize app logic into single-purpose “Action” classes that can run as controllers, jobs, listeners, commands, and more. Define a handle method for the core task, then add asController/asJob/etc wrappers to reuse the same logic across contexts.
Architectural Shift from Controllers to Domain-Driven Actions:
Adopt a task-centric design where logic is organized by what the application does (e.g., PublishArticle, ProcessPayment) rather than by HTTP layers or event types. This aligns with Domain-Driven Design (DDD) principles and reduces boilerplate (e.g., no need to duplicate logic in controllers, jobs, and listeners).
Accelerate Feature Delivery:
asJob) or event-driven actions (e.g., asListener) without coupling to Laravel’s traditional patterns.Use Cases:
CreateUser, GenerateReport).OrderPlaced into a single ProcessOrder action.BackupDatabase).Action::run($params)).Tech Debt Reduction:
handle() instead of scattering it across FormRequests and controllers.SendEmail action used in both controllers and jobs).FulfillOrder, RefundPayment)."Laravel Actions lets us build faster and maintain cleaner code by focusing on what the app does—not how it’s wired together. For example, instead of writing separate controllers, jobs, and listeners for ‘publishing an article,’ we define one PublishArticle action that works everywhere. This cuts development time by 30–50% for new features, reduces bugs from duplicated logic, and makes the codebase easier to scale. It’s like using LEGO blocks instead of soldering circuits—we assemble workflows quickly and reuse them anywhere."
ROI Highlights:
*"This package eliminates boilerplate by letting us define actions as pure PHP classes (e.g., class CreateInvoice { ... }) and reuse them as controllers, jobs, listeners, or CLI commands. Key wins:
handle().Action::run()).Migration Path:
php artisan make:action to scaffold new workflows.Route::post('/signup', CreateUser::class)).Trade-offs:
handle() focused).Try it on a new feature first—if it saves 2+ hours per endpoint, it’s worth adopting."*
How can I help you explore Laravel packages today?