Download the PHP package laraditz/action without Composer
On this page you can find all versions of the php package laraditz/action. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laraditz/action
More information about laraditz/action
Files in laraditz/action
Package action
Short Description A simple single action class for Laravel to keep your application DRY
License MIT
Homepage https://github.com/laraditz/action
Informations about the package action
Laravel Action
Single action class for Laravel to keep your application DRY. Each action encapsulates one business operation, receives its input through the constructor, and resolves services automatically via Laravel's container.
Requirements
- PHP 8.2+
- Laravel 9 – 13
Installation
Creating an Action
Use the Artisan command to generate an action class (placed in app/Actions/ by default):
Fill in the generated file:
Running an Action
Instance style — construct first, then call run():
Static style — constructor arguments are passed directly to run():
Both styles are equivalent.
Dependency Injection
Type-hint services in handle() and Laravel's container injects them automatically:
Queue Support
Make an action queueable by implementing ShouldQueue and adding the standard Laravel queue traits. Do not add Dispatchable — the base Action class already provides dispatch().
Dispatching to the queue:
When the queue worker processes the job, Laravel's CallQueuedHandler calls handle() through the container, so type-hinted dependencies are injected automatically — the same as when running synchronously.
Note: Do not add
use Illuminate\Foundation\Bus\Dispatchableto your action class. The baseActionclass already providesdispatch(), and adding the trait will cause a conflict.
The data() Helper
data() returns all constructor-promoted properties as a key–value array, which is handy for mass-assignment:
Actions with no constructor return an empty array from data().
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.
All versions of action with dependencies
illuminate/bus Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^9.0|^10.0|^11.0|^12.0|^13.0