PHPackages                             lzpeng/php-state-processor - 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. lzpeng/php-state-processor

ActiveLibrary

lzpeng/php-state-processor
==========================

状态流转处理器

1.3.1(5y ago)023Apache License 2.0PHPPHP &gt;=7.1CI failing

Since Jun 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/liuzhanpeng/php-state-processor)[ Packagist](https://packagist.org/packages/lzpeng/php-state-processor)[ RSS](/packages/lzpeng-php-state-processor/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

php-state-processor
===================

[](#php-state-processor)

状态流转处理器

概念
--

[](#概念)

- State 状态对象
- DomainObject 需要状态流转的业务域对象, 必须实现 \\Lzpeng\\StateProcess\\Contracts\\StatefulInterface
- Action 状态流转时执行的动作
- Transition 流转的抽象表示

使用方式
----

[](#使用方式)

```
$transitions = [
    'init' => [
        'from' => ['unknown'], // 来源状态
        'to' => 'inited', // 转换后的状态
        'action' => SubmitAction::class, // 状态转换时执行的动作
    ],
    'audit' => [
        'from' => ['inited'],
        'to' => 'audited',
        'action' => AuditAction::class,
    ], ...
];

// 动作与最终状态更改需要在同一事务中，保证原子性
// 通过 \Lzpeng\StateProcess\Contracts\TxInterface 实现自己的事务对象
$txCreator = NullTx::class;

$processor = Factory::create($transitions, $txCreator);

// 业务域对象
$order = new Order();
$order->setState(new State('unknown'));

// 判断是否能执行指定流转
if ($processor->can('init', $order)) {
    // ...
}

// 执行流转
try {
    $processor->execut('init', $order);
} catch(StateException $ex) {
    // exception handle
}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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

Every ~3 days

Total

5

Last Release

2137d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b085c9e9145b16a586a1574c9ece3fc1793c14c0d120f9f3c74b301b19165925?d=identicon)[liuzhanpeng](/maintainers/liuzhanpeng)

---

Top Contributors

[![liuzhanpeng](https://avatars.githubusercontent.com/u/6972018?v=4)](https://github.com/liuzhanpeng "liuzhanpeng (24 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lzpeng-php-state-processor/health.svg)

```
[![Health](https://phpackages.com/badges/lzpeng-php-state-processor/health.svg)](https://phpackages.com/packages/lzpeng-php-state-processor)
```

PHPackages © 2026

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