nowi5/laravel-workflow
Composer 安装命令:
composer require nowi5/laravel-workflow
包简介
Workflow Engine for Laravel
README 文档
README
The Laravel Workflow Jobs package allows you to effortlessly create workflows that run as jobs with robust logging capabilities. Use this package to design, execute, and monitor workflow processes using Laravel jobs and enjoy a seamless experience with dynamic parameter passing and custom logic evaluations.
Installation
-
Install the package via composer:
composer require laravel-workflow-jobs-package -
Publish the config file:
php artisan vendor:publish --provider="Workflow\WorkflowServiceProvider" -
Run migrations (if needed) to set up the required tables for logging and management:
php artisan migrate
Usage
Creating a Workflow
To create a workflow, you can define it as shown in the example:
namespace App\Workflow; use App\Jobs\WorkflowStepJob; use Workflow\Workflow; class ExampleWorkflow extends Workflow { public $name = "TestWorkflow"; public $version = "1.0.0"; public function execute(){ // Adding steps to the workflow $this->addStep("step1", WorkflowStepJob::class, ["param1" => "some value"]); // Setting the logic for the workflow $this->addLogic("step1", "step2"); } }
Running a Workflow
After defining your workflow, you can start and fetch its JSON representation:
$workflow = new ExampleWorkflow(); $workflow->start("Hello Test"); $workflowjson = $workflow->getJson(); return response("<pre><code>".$workflowjson."</code></pre>", 200);
Creating a Workflow Step (Job)
Each step in a workflow corresponds to a Laravel job. To create a custom workflow job:
namespace App\Jobs; use Workflow\Jobs\WorkflowJob; class WorkflowStepJob extends WorkflowJob { public $name = "Example Step Name"; // Keep this unique public $version = "1.0.0"; public function execute() { $content = "Hello Custom Workflow, " . now() . "\n"; return ['content' => $content]; } }
Dynamic Parameter Passing
You can pass parameters from one step's output to another's input dynamically using the format %stepName.parameterName%:
$this->addStep("step2", WorkflowStepJob::class, ["param1" => "%step1.randomNumber%"]);
Custom Logic Evaluation
You can also define custom logic evaluations to determine which step to execute next based on the output of the previous steps: Defining own logic for the workflow as well as adding logic at all is optional. If no logic is defined, the workflow will execute all steps in the order they were added.
$this->addLogic("step3", null, [ ["evaluate" => "%step2.outputParameterName%", "comparison" => "<50", "next" => "step5"], ["evaluate" => "%step2.outputParameterName%", "comparison" => ">=50", "next" => "step4"] ]);
Contributing
If you'd like to contribute to this project, please submit a PR or open an issue. We appreciate any feedback or improvements!
License
This package is open-source software licensed under the MIT license.
Notes
"Laravel" is a registered trademark of Taylor Otwell. This project is not affiliated, associated, endorsed, or sponsored by Taylor Otwell, nor has it been reviewed, tested, or certified by Taylor Otwell. The use of the trademark "Laravel" is for informational and descriptive purposes only. Laravel Workflow is not officially related to the Laravel trademark or Taylor Otwell.
nowi5/laravel-workflow 适用场景与选型建议
nowi5/laravel-workflow 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 08 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 nowi5/laravel-workflow 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nowi5/laravel-workflow 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-07