PHPackages                             verdient/pm2 - 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. [CLI &amp; Console](/categories/cli)
4. /
5. verdient/pm2

ActiveLibrary[CLI &amp; Console](/categories/cli)

verdient/pm2
============

pm2 process manager bridge

0.0.2(6y ago)0551[1 PRs](https://github.com/Verdient/pm2/pulls)MITPHPPHP &gt;=7.0.0

Since Feb 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Verdient/pm2)[ Packagist](https://packagist.org/packages/verdient/pm2)[ Docs](https://github.com/Verdient/pm2)[ RSS](/packages/verdient-pm2/feed)WikiDiscussions master Synced 6d ago

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

PM2
===

[](#pm2)

通过PHP控制PM2进程管理器

安装
--

[](#安装)

```
composer require verdient/pm2

```

配置脚本
----

[](#配置脚本)

```
use Verdient\pm2\PM2;

/**
 * 是否允许合并操作
 * 对于支持合并的操作，如果设置为true，则会对进程进行批量操作
 * 否则会依次对各个进程进行操作
 * 可选参数，默认为true
 */
$enableMerge = true;

/**
 * 是否跳过环境检查
 * 对于确定安装了PM2的系统，将该配置项设置为true，跳过环境检查
 * 否则每次运行都会检查PM2的安装状态
 * 可选参数，默认为false
 */
$skipEnvironmentCheck = false;

/**
 * 脚本配置，格式为[$name => $config]的数组
 * $config 可以为字符串也可以为数组
 * 当$config为数组时，等同于仅配置了数组的$config['script']
 * 当$config为数组时：
 *     script 运行的脚本，与cwd一起组成完成的脚本路径
 *     cwd 脚本运行的文件夹
 *     args 需要传递给脚本的参数，默认为空数组
 *     interpreter 解释脚本的程序，默认为php
 *     interpreter_args 需要传递给解释程序（interpreter）的参数
 * 程序以$name作为唯一标识，所以$name不允许重复
 */
$scripts = [
	'test' => [
		'script' => 'index.php',
		'cwd' => __DIR__,
		'args' => [],
		'interpreter' => 'php',
		'interpreter_args' => []
	],
	'test2' => __DIR__ . DIRECTORY_SEPARATOR . 'index.php',
];

$pm2 = new PM2([
		'scripts ' => $scripts,
		'skipEnvironmentCheck' => $skipEnvironmentCheck,
		'enableMerge' => $enableMerge
	]
]);
```

启动脚本
----

[](#启动脚本)

```
/**
 * 要操作的脚本名称
 * 默认为空数组，既操作所有配置的脚本
 * stop restart delete reset方法$names参数含义与此相同
 */
$names = [];
/**
 * 附加的参数
 * 具体参数见 https://pm2.keymetrics.io/docs/usage/startup/
 */
$args = [];
$pm2->start($names, $args);
```

停止脚本
----

[](#停止脚本)

```
$pm2->stop($names = []);
```

重启脚本
----

[](#重启脚本)

```
$pm2->restart($names = []);
```

重置脚本
----

[](#重置脚本)

```
$pm2->reset($names = []);
```

删除脚本
----

[](#删除脚本)

```
$pm2->delete($names = []);
```

事件挂载
----

[](#事件挂载)

如果需要对操作的过程进行观察监控，可以通过挂载事件来实现

```
$pm2->on(PM2::EVENT_START, function($started, $count, $names){
	echo '已启动' . $started . '个进程，共需启动' . $count . '个进程，名字分别为：' . implode(', ', $names) . PHP_EOL;
});

$pm2->on(PM2::EVENT_STOP, function($started, $count, $names){
	echo '已停止' . $started . '个进程，共需停止' . $count . '个进程，名字分别为：' . implode(', ', $names) . PHP_EOL;
});

$pm2->on(PM2::EVENT_RESTART, function($started, $count, $names){
	echo '已重启' . $started . '个进程，共需重启' . $count . '个进程，名字分别为：' . implode(', ', $names) . PHP_EOL;
});

$pm2->on(PM2::EVENT_RESET, function($started, $count, $names){
	echo '已重置' . $started . '个进程，共需重置' . $count . '个进程，名字分别为：' . implode(', ', $names) . PHP_EOL;
});

$pm2->on(PM2::EVENT_DELETE, function($started, $count, $names){
	echo '已删除' . $started . '个进程，共需删除' . $count . '个进程，名字分别为：' . implode(', ', $names) . PHP_EOL;
});
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

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

Total

3

Last Release

2228d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/606eaa4bc61b11fa19f25526a3084758b7086ceb8b11cdbcafd5df11871f2437?d=identicon)[Verdient。](/maintainers/Verdient%E3%80%82)

---

Top Contributors

[![Verdient](https://avatars.githubusercontent.com/u/22468867?v=4)](https://github.com/Verdient "Verdient (5 commits)")

---

Tags

processmanagerBridgepm2

### Embed Badge

![Health badge](/badges/verdient-pm2/health.svg)

```
[![Health](https://phpackages.com/badges/verdient-pm2/health.svg)](https://phpackages.com/packages/verdient-pm2)
```

###  Alternatives

[titasgailius/terminal

Terminal is an Elegent wrapper around Symfony's Process component.

512340.9k11](/packages/titasgailius-terminal)[hjbdev/pvm

PHP Version Manager for Windows CLI

2784.1k](/packages/hjbdev-pvm)[ptlis/shell-command

A basic wrapper around execution of shell commands.

2256.0k2](/packages/ptlis-shell-command)

PHPackages © 2026

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