michielkempen / laravel-actions
Requires
- php: ^8.0
- ext-json: *
- laravel/framework: ^7.31|^8.40
- michielkempen/laravel-enum: ^1.0
- michielkempen/laravel-uuid-model: ^3.0
- spatie/async: ^1.5
Requires (Dev)
- orchestra/testbench: ^6.0
- dev-master
- 6.0.0
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 4.5.4
- 4.5.3
- 4.5.2
- 4.5.1
- 4.5.0
- 4.4.5
- 4.4.4
- 4.4.3
- 4.4.2
- 4.4.1
- 4.4.0
- 4.3.0
- 4.2.1
- 4.2.0
- 4.1.0
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.4.0
- 3.3.0
- 3.2.7
- 3.2.6
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.0
- 3.0.0
- v2.x-dev
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.0.2
- 0.0.1
- dev-change-on-model-method-signature
This package is auto-updated.
Last update: 2021-08-03 18:49:54 UTC
README
This package was inspired by Spatie's Laravel Queueable Action package.
As mentioned in the documentation of Spatie's package, actions are a way of structuring your business logic in Laravel. A detailed blogpost discussing the reasoning behind actions and their asynchronous usage can be found via this link.
This package builds on top of the idea of asynchronous actions, and adds a mechanism to track the state of queued actions in real-time.
Installation
Add the package to the dependencies of your application
composer require michielkempen/laravel-actions
The package will automatically register itself.
You can publish the migration with:
php artisan vendor:publish --provider="MichielKempen\LaravelActions\ActionsServiceProvider" --tag="migrations"
After the migration has been published you can create the queued_action_chains
and queued_actions
database tables
by running:
php artisan migrate
Usage
Synchronous action chain execution:
$uuid = (string) Uuid::generate(4); (new QueueableActionChain) ->addAction(ReturnTheFirstParameterAsOutputAction::class, ['hello', 'world'], "Greetings!", $uuid) ->addAction(ReturnTheParametersAsOutputAction::class, ['john', 'doe']) ->addAction(ReturnTheParametersAsOutputAction::class, [new ActionOutput($uuid), 'joe'], "Test action output") ->withCallback(ReturnStatusCallback::class) ->execute();
Asynchronous action chain execution:
$uuid = (string) Uuid::generate(4); $model = TestModel::create(); (new QueueableActionChain) ->queue() ->onModel($model) ->withName("Test action") ->addAction(ReturnTheFirstParameterAsOutputAction::class, ['hello', 'world'], "Greetings!", $uuid) ->addAction(ReturnTheParametersAsOutputAction::class, ['john', 'doe']) ->addAction(ReturnTheParametersAsOutputAction::class, [new ActionOutput($uuid), 'joe'], "Test action output") ->withCallback(ReturnStatusCallback::class) ->execute();
Security
If you discover any security related issues, please email kempenmichiel@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.