PHPackages                             zbin/php-deamon - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. zbin/php-deamon

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zbin/php-deamon
===============

基于swoole守护进程，目前支持框架：yii2

1.0.7(8y ago)146MITPHPPHP &gt;=5.6.1

Since Mar 16Pushed 7y ago1 watchersCompare

[ Source](https://github.com/showyouself/php-deamon)[ Packagist](https://packagist.org/packages/zbin/php-deamon)[ Docs](https://github.com/showyouself/php-deamon)[ RSS](/packages/zbin-php-deamon/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (1)Versions (9)Used By (0)

php-deamon
==========

[](#php-deamon)

php守护进程框架+

使用场景
----

[](#使用场景)

需要一个程序一直在console循环执行，例如轮询消费队列消息等。

一、安装
----

[](#一安装)

```
composer require zbin/php-deamon

```

相关配置
----

[](#相关配置)

$processConfig轮询脚本配置

- action\_path ：执行的脚本格式"控制器/方法"
- run\_interval ：运行间隔(秒)
- param ： 传入参数

$swooleConfig主进程配置

- daemonize ：0:debug，1:后台运行
- foot\_ip ：ip
- foot\_port ： 监听端口，swoole默认9501
- message\_queue\_id ：轮询脚本反馈消息队列id，例如：0x0104a8a2

    ```
    $new = new footman($processConfig, $swooleConfig);

    ```

二、在框架中使用
--------

[](#二在框架中使用)

### yii2框架

[](#yii2框架)

新建一个footman对象，传入processConfig数组，如下脚本在每次执行完成后间隔的时间

- commands/SonController.php/actionTest 间隔10秒执行一次
- commands/SunController.php/actionRun 间隔5秒执行一次

    ```

    &lt;?php

    namespace app\\commands;

    use yii\\console\\Controller;

    use zbin\\footman;

class HelloController extends Controller { public function actionIndex($message = 'hello world') { $processConfig = \[ \[ 'action\_path' =&gt; 'sub/run', 'run\_interval' =&gt; 5, 'param' =&gt; \['ben', 25,\] \], \[ 'action\_path' =&gt; 'son/test', 'run\_interval' =&gt; 10, 'param' =&gt; \['zeng', 2018,\] \] \]; // run in background 后台运行 // $swooleConfig = \['daemonize' =&gt; 1\]; // $new = new footman($processConfig, $swooleConfig); $new = new footman($processConfig); $new-&gt;run(); } }

```
## 三、查看运行状态
直接使用http请求host:9501端口，即可得到运行状态，目前支持的入参为：
* show : 1、detail
* action_path : 循环执行的脚本名 例如：sub-run

```

curl "127.0.0.1:9501?show=detail" 或者(如果不希望浏览器可以访问，建议关闭出网端口) view-source:

```
得到的结果如下：

```

&lt;&lt;=========\[son/test\]=========&gt;&gt; run\_count : 36 run\_interval : 10 last\_start\_time : 2018-03-24 06:37:20 last\_end\_time : 2018-03-24 06:37:20 last\_run\_msg : success last\_run\_ret : 0 run\_param : \["ben",25\]

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~1 days

Total

8

Last Release

2975d ago

Major Versions

v0.9 → 1.0.22018-03-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ba4d1804bc3e0650f3aab0ff7ff8e1db7d400201c9bfa5efba44db7de1aaa09?d=identicon)[showyouself](/maintainers/showyouself)

---

Top Contributors

[![showyouself](https://avatars.githubusercontent.com/u/22185883?v=4)](https://github.com/showyouself "showyouself (52 commits)")

---

Tags

phpswooleyii2php-deamon让yii2跑在swoole上

### Embed Badge

![Health badge](/badges/zbin-php-deamon/health.svg)

```
[![Health](https://phpackages.com/badges/zbin-php-deamon/health.svg)](https://phpackages.com/packages/zbin-php-deamon)
```

PHPackages © 2026

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