michielkempen / laravel-actions
6.0.0
2021-08-03 18:49 UTC
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
此包受到 Spatie 的 Laravel Queueable Action 包 的启发。
如 Spatie 包的文档所述,操作是结构化 Laravel 中的业务逻辑的一种方式。关于操作及其异步使用的详细博客文章,可以通过 此链接 查看。
此包在异步操作想法的基础上进行了扩展,并添加了一个机制来实时跟踪队列操作的状态。
安装
将包添加到应用程序的依赖项中
composer require michielkempen/laravel-actions
该包将自动注册自己。
您可以使用以下命令发布迁移
php artisan vendor:publish --provider="MichielKempen\LaravelActions\ActionsServiceProvider" --tag="migrations"
在迁移发布后,您可以通过运行以下命令创建 queued_action_chains
和 queued_actions
数据库表
php artisan migrate
使用
同步操作链执行
$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();
异步操作链执行
$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();
安全性
如果您发现任何与安全性相关的问题,请通过电子邮件 kempenmichiel@gmail.com 联系,而不是使用问题跟踪器。
致谢
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。