Laractions Package Moves Laravel Business Logic Out of Controllers into Action Classes
Laractions is a Composer package for Laravel that extracts business logic from bloated controller methods into dedicated, single-purpose action classes. Controllers often accumulate responsibilities over time — such as database writes, emails, and logging — that should not live alongside request-handling code. The package provides an Artisan generator to scaffold action classes under App\Actions, with dependency injection supported via Laravel's service container. A refactored controller simply validates the request and delegates to the action using a fluent run() method, which forwards arguments to the action's handle() method. The package also supports model-bound actions, allowing developers to scope operations like cancellations directly to an Eloquent model instance.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in