PHPackages                             zrone/hyperf-workflow - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. zrone/hyperf-workflow

ActiveL

zrone/hyperf-workflow
=====================

workflow

v0.0.1(4y ago)091MITPHPPHP &gt;=7.2

Since Jul 23Pushed 4y ago1 watchersCompare

[ Source](https://github.com/zrone/hyperf-workflow)[ Packagist](https://packagist.org/packages/zrone/hyperf-workflow)[ RSS](/packages/zrone-hyperf-workflow/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Hyperf 工作流
==========

[](#hyperf-工作流)

安装
--

[](#安装)

```
composer require zrone/hyperf-workflow

```

安装完成后执行

```
php bin/hyperf.php vendor:publish zrone/hyperf-workflow

```

使用
--

[](#使用)

```
public function index(WorkflowRegistry $workflowRegistry)
    {
        // 模型对象，这里仅做演示，请勿在controller直接使用model查询对象
        $wf = Workflow::query()->find(1);

        // 初始化工作流
        $registry = $workflowRegistry->create();
        // 获取当前工作流
        $wfr = $registry->get($wf, 'workflow_name');

        // 执行工作流
        if ($wfr->can($wf, 'to_review')) {
            try {
                $wfr->apply($wf, 'to_review');
                // logic

                // log
            } catch (\Exception $exception) {
                // exception
            }
        }

        return [
            'message' => 'message loading'
        ];
    }

```

### 工作流单元执行 Event

[](#工作流单元执行-event)

```
class WorkflowService
{
    /**
     * @Inject
     * @var ContainerInterface $container
     */
    public $container;

    public function toReview(Event $event)
    {
        // event
        // ...
        var_dump(1);
        var_dump($event->getMetadata('label', $event->getTransition()));
    }

    public function publish(Event $event)
    {
        var_dump(2);
    }

    public function reject(Event $event)
    {
        var_dump(3);
    }
}

```

### 详细配置

[](#详细配置)

```
return [
    [
        'name' => 'workflow_name',
        // 状态
        'places' => [
            'draft',
            'reviewed',
            'rejected',
            'published',
        ],
        // 工作流
        'transitions' => [
            ['name' => 'to_review', 'from' => 'draft', 'to' => 'reviewed', 'event' => [\App\Services\WorkflowService::class, 'toReview']],
            ['name' => 'publish', 'from' => 'reviewed', 'to' => 'published', 'event' => null],
            ['name' => 'reject', 'from' => 'reviewed', 'to' => 'rejected', 'event' => null],
        ],
        // uml 备注信息
        'attaches' => [
            'to_review' => '审核1',
            'publish' => '审核2',
            'reject' => '审核3',
        ],
        'places_metadata' => [
            'draft' => ["bg_color" => 'red', 'description' => 'draft',],
            'reviewed' => ["bg_color" => 'red', 'description' => 'draft',],
            'rejected' => ["bg_color" => 'red', 'description' => 'draft',],
            'published' => ["bg_color" => 'red', 'description' => 'draft',],
        ],
        // 工作流工作每次只允许改变到下一级状态，不允许一个工作流跳跃多个place
        'single_state' => true,
        // 关联 model
        'model' => \App\Model\Workflow::class,
        // model标记状态的字段名
        'property' => 'currentState',
        'dispatcher' => [
            'guard' => null
        ],
    ]
];

```

### 使用 UML 生成流程图

[](#使用-uml-生成流程图)

[Graphviz](https://www.graphviz.org/), 安装 Graphviz
[PlantUML](https://plantuml.com/) 下载 PlantUML.jar，机器需要安装jdk，配置java运行环境

windows Graphviz 安装包 [https://pan.baidu.com/s/1oH7S2hIat8a7\_qeQkiv78w](https://pan.baidu.com/s/1oH7S2hIat8a7_qeQkiv78w) 提取码: 5t1h

#### Liunx &amp; Mac

[](#liunx--mac)

下载 `workflow` 到项目根目录 链接: [https://pan.baidu.com/s/1WeXCznhKrZ\_XqBFcpQEafg](https://pan.baidu.com/s/1WeXCznhKrZ_XqBFcpQEafg) 密码: i7gm 在项目根目录下 `projectDir` 执行命令生成uml

```
workflow

```

#### Windows

[](#windows)

下载 `workflow.exe` 到项目根目录 链接：[https://pan.baidu.com/s/1eaRybp\_evIzppfDPaqBw6A](https://pan.baidu.com/s/1eaRybp_evIzppfDPaqBw6A) 提取码：7p9l 在项目根目录下 `projectDir` 执行程序即可生成uml

```
workflow.exe

```

生成的目录在 `projectDir/uml` 下

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1751d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9620247?v=4)[zrone](/maintainers/zrone)[@zrone](https://github.com/zrone)

---

Top Contributors

[![zrone](https://avatars.githubusercontent.com/u/9620247?v=4)](https://github.com/zrone "zrone (12 commits)")

### Embed Badge

![Health badge](/badges/zrone-hyperf-workflow/health.svg)

```
[![Health](https://phpackages.com/badges/zrone-hyperf-workflow/health.svg)](https://phpackages.com/packages/zrone-hyperf-workflow)
```

###  Alternatives

[symfony/http-kernel

Provides a structured process for converting a Request into a Response

8.1k822.4M6.7k](/packages/symfony-http-kernel)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k235.4M9.6k](/packages/symfony-framework-bundle)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M1.9k](/packages/behat-behat)[symfony/form

Allows to easily create, process and reuse HTML forms

2.8k152.1M2.8k](/packages/symfony-form)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k172.9M1.8k](/packages/symfony-security-bundle)[symfony/mailer

Helps sending emails

1.6k368.1M952](/packages/symfony-mailer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
