Download the PHP package defstudio/actions without Composer
On this page you can find all versions of the php package defstudio/actions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download defstudio/actions
More information about defstudio/actions
Files in defstudio/actions
Package actions
Short Description Helpers methods for Laravel Actions
License MIT
Homepage https://github.com/defstudio/actions
Informations about the package actions
Helpers methods for Laravel Actions
an opinionated lightweight package for creating Action classes
Installation
You can install the package via composer:
Usage
Add use DefStudio\Actions\ActAsAction;
trait to your action class or extend DefStudio\Actions\Action
(optional) add a dockblock to hint the static run
method parameters and return types
Use the new methods:
Run multiple actions as once
an action can be run multiple times by calling its runMany()
method
each run's result will be collected in an array and returned by runMany()
notes
if multiple parameters are required, they can be wrapped in an array (associative array keys will be treated as named arguments):
Mockable actions
Also, you can define a mock for the action (it will be authomatically bound to the app container):
if you are interested in only mocking the return value, you can write:
if your action has public methods other than handle
, they can be mocked as well:
without arguments, mocks
returns a MockInterface instance ready to be used
a partial mock (i.e. for actions with more than a single method)
along with mocks, actions can also be spied:
Dispatchable actions
An action can be made dispatchable as a job with the ActsAsJob
trait (or extending the Action
class)
a job can be created by calling the job()
static method:
or can be dispatched with its dedicated methods:
The action will be dispatched wrapped in a ActionJob decorator that will proxy properties as needed:
Cleaning up after failed action job
Failed action jobs can be handled by defining a jobFailed()
method:
Batches and Chains of action jobs
Similarly to the runMany()
method, a new batch/chain of action jobs can be created starting from an array of parameters:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Fabio Ivona
- All Contributors
This project was inspired and is built as an opinionated and simplified implementation of Loris Leiva's Laravel Actions. For a more powerful tool, you should take a look at it.
License
The MIT License (MIT). Please see License File for more information.
All versions of actions with dependencies
spatie/laravel-package-tools Version ^1.9.2
illuminate/contracts Version ^8.37|^9.0|^10.0