You can install the package via composer:
composer require jalallinux/php-pm2- Full name: \JalalLinuX\Pm2\Pm2
list ❓
Fetch list all running applications
pm2()->list(string $sortField = 'name', bool $desc = true): array<Process>Parameters:
| Parameter | Type | Description |
|---|---|---|
sortField |
string | Sort field: name, id, pid, memory, cpu, status, uptime |
desc |
bool | Sort order is descending |
link ❓
Connect your server to your dashboard and start collecting metrics
pm2()->link(string $publicKey, string $secretKey, string|null $machineName = null): boolParameters:
| Parameter | Type | Description |
|---|---|---|
publicKey |
string | PM2 account PUBLIC_KEY |
secretKey |
string | PM2 account SECRET_KEY |
machineName |
?string | Machine name on the dashboard |
unlink ❓
Disconnect your server from your metrics dashboard
pm2()->unlink(): boolstart ❓
Start command with specifics options or start a ecosystem.config.js
pm2()->start(string $command = null, array $options = []): boolParameters:
| Parameter | Type | Description |
|---|---|---|
command |
?string | Command to run in pm2 |
options |
array | Options to start pm2 command Guide like ['name' => 'process-1', 'no-autorestart'] |
findBy ❓
Find specific process
pm2()->findBy(string $key, string $value): \JalalLinuX\Pm2\Structure\Process|nullParameters:
| Parameter | Type | Description |
|---|---|---|
key |
string | Key of property to find process |
value |
string | Value of key |
kill daemon
pm2()->kill(): boolFetch pid of specific process
pm2()->pid(string $name): int|nullParameters:
| Parameter | Type | Description |
|---|---|---|
name |
string | Name of process |
flush ❓
Empty all log files
pm2()->flush(): boolupdate ❓
Update in memory pm2
pm2()->update(): mixedstopAll ❓
Stop all processes
pm2()->stopAll(): boolrestartAll ❓
Restart all processes
pm2()->restartAll(): booldeleteAll ❓
Will stop and delete all processes from pm2 list
pm2()->deleteAll(): boolstop ❓
Stop specific process
pm2()->stop(string $idOrName): boolParameters:
| Parameter | Type | Description |
|---|---|---|
idOrName |
string | Id or name of process |
restart ❓
Restart specific process
pm2()->restart(string $idOrName): boolParameters:
| Parameter | Type | Description |
|---|---|---|
idOrName |
string | Id or name of process |
delete ❓
Delete specific process
pm2()->delete(string $idOrName): boolParameters:
| Parameter | Type | Description |
|---|---|---|
idOrName |
string | Id or name of process |
save ❓
Freeze a process list for automatic respawn
pm2()->save(bool $force = true): boolParameters:
| Parameter | Type | Description |
|---|---|---|
force |
bool | Force save list |
logOut ❓
Display all processes output logs
pm2()->logOut(string $idOrName = null, int $lines = 100): stringParameters:
| Parameter | Type | Description |
|---|---|---|
idOrName |
?string | Id or name of process |
lines |
int | To dig in older logs |
logErr ❓
Display all processes error logs
pm2()->logErr(string $idOrName = null, int $lines = 100): stringParameters:
| Parameter | Type | Description |
|---|---|---|
idOrName |
?string | Id or name of process |
lines |
int | To dig in older logs |
startup ❓
Generate an active startup script
pm2()->startup(): boolversion ❓
Fetch installed pm2 version
pm2()->version(): stringinstall ❓
Install PM2 (Requirements: node, npm)
pm2()->install(string $version = 'latest'): false|string|nullParameters:
| Parameter | Type | Description |
|---|---|---|
version |
string | Specific version |
Check if the PM2 is installed
pm2()->isInstall(bool $forceInstall = false, string $version = 'latest'): boolParameters:
| Parameter | Type | Description |
|---|---|---|
forceInstall |
bool | Install pm2 if is not installed |
version |
string | Specific version |
composer testPlease see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.
