lorisleiva/laravel-actions
Unify your Laravel app logic into single-purpose “Action” classes that can run as controllers, jobs, listeners, or commands. Keep business logic in one place, reduce duplication, and generate actions via artisan with flexible asX entrypoints.
Architectural Shift from Controllers to Task-Oriented Design:
Adopt a domain-driven approach where actions encapsulate single responsibilities (e.g., PublishArticle, ProcessPayment). This aligns with clean architecture principles, reducing controller bloat and improving maintainability.
Accelerate Feature Development:
asController, asJob, asCommand) to standardize execution paths.SendEmailNotification in both web and CLI contexts).Use Cases:
GenerateReport::asController()).SyncUserProfile::asListener()) for decoupled event handling.BackupDatabase::asCommand() and asJob()).php artisan make:action --test), reducing boilerplate.Performance Optimization:
Action::run()) to avoid framework overhead (e.g., in scheduled tasks).asController() with auth:api).Team Scalability:
PaymentTeam owns ProcessRefund).Adopt When:
Look Elsewhere If:
"Laravel Actions lets us build faster and scale cleaner. Instead of writing spaghetti controllers that mix HTTP logic with business rules, we’ll organize code by what the app does—like ProcessOrder, SendInvoice, or SyncData. This reduces technical debt, makes features reusable across projects, and lets our team ship high-quality code 30% faster (based on similar adopters). It’s like upgrading from procedural code to functions—just for Laravel."
Key Outcomes:
AuthenticateUser in web and API).*"This package eliminates boilerplate while enforcing clean architecture. No more:
How It Works:
CreateUserSubscription) with a handle() method for core logic.// HTTP
Route::post('/subscribe', CreateUserSubscription::class);
// Queue
CreateUserSubscription::dispatch($user, $plan);
// Event
Event::listen(UserUpgraded::class, CreateUserSubscription::class);
Why Now?
Migration Path: Start with new features—create actions for critical paths (e.g., payments, user flows). Gradually refactor legacy controllers into actions.
Risk Mitigation:
How can I help you explore Laravel packages today?