Laravel Actions
Organize your Laravel logic into single-task classes that run as controllers, jobs, listeners, commands, or objects.
Repository Health
Technical Analysis
Laravel Actions introduces a way of organizing the logic of your Laravel applications around the actions they provide rather than around framework primitives. Instead of scattering behavior across controllers, jobs, listeners, and console commands, you write one PHP class per task and then run that class as any of those things.
A single action class can be invoked as an HTTP controller, dispatched as a queued or synchronous job, hooked up as an event listener, registered as an artisan command, or simply called as a plain object, all from the same implementation. This keeps business logic in one discoverable place, reduces boilerplate, and shifts the design question from “what controller/job do I need?” to “what does my application actually do?”.
What You Get
- Single-responsibility action classes runnable as controller, job, listener, command, or object
- As* traits (AsController, AsJob, AsListener, AsCommand) to opt into each execution context
- Built-in validation and authorization on the action, reused across contexts
- Job chaining, scheduling, and artisan command registration for actions
- Extensive test coverage demonstrating every supported usage mode
Common Use Cases
- Consolidating a feature’s logic into one class instead of separate controller and job files
- Reusing the same operation as both an HTTP endpoint and a queued background job
- Exposing application tasks as artisan commands without duplicating logic
Under The Hood
Architecture
The package registers through ActionServiceProvider and centers on an Action/ActionManager pair plus a set of Concerns and Decorators. Each execution context is expressed as a trait (in Concerns) that layers behavior onto a plain action class: as a controller it runs through an ActionRequest and AttributeValidator for validation/authorization; as a job it wraps into a dispatchable decorator supporting chaining (ActionPendingChain); as a command it builds an artisan command via the Console layer; as a listener it hooks the event system. A DesignPatterns directory captures the reusable strategies for these transformations, and Facades expose a convenient entry point.
Tech Stack
PHP 8.2+, depending only on illuminate/contracts (Laravel 11 through 13) and the author’s lorisleiva/lody helper for class discovery. It autoloads via PSR-4 under Lorisleiva\Actions and integrates with Laravel through its service provider.
Code Quality
The codebase is mature and thoroughly tested: the tests directory contains dozens of scenario files exercising each mode (AsController, AsJob, AsCommand, AsListener, validated attributes, scheduling, chaining). Logic is cleanly separated into concerns, decorators, and design-pattern classes, reflecting years of iteration and a large contributor base.
API Design
The developer experience is a highlight: you write one class, add the traits for the contexts you need, and implement a single handle method. Rich official documentation at laravelactions.com covers each mode. The concept requires a mental shift from framework-primitive thinking, which is the main source of its moderate learning curve.