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): bool
Parameters:
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(): bool
start ❓
Start command with specifics options or start a ecosystem.config.js
pm2()->start(string $command = null, array $options = []): bool
Parameters:
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|null
Parameters:
Parameter | Type | Description |
---|---|---|
key |
string | Key of property to find process |
value |
string | Value of key |
kill daemon
pm2()->kill(): bool
Fetch pid of specific process
pm2()->pid(string $name): int|null
Parameters:
Parameter | Type | Description |
---|---|---|
name |
string | Name of process |
flush ❓
Empty all log files
pm2()->flush(): bool
update ❓
Update in memory pm2
pm2()->update(): mixed
stopAll ❓
Stop all processes
pm2()->stopAll(): bool
restartAll ❓
Restart all processes
pm2()->restartAll(): bool
deleteAll ❓
Will stop and delete all processes from pm2 list
pm2()->deleteAll(): bool
stop ❓
Stop specific process
pm2()->stop(string $idOrName): bool
Parameters:
Parameter | Type | Description |
---|---|---|
idOrName |
string | Id or name of process |
restart ❓
Restart specific process
pm2()->restart(string $idOrName): bool
Parameters:
Parameter | Type | Description |
---|---|---|
idOrName |
string | Id or name of process |
delete ❓
Delete specific process
pm2()->delete(string $idOrName): bool
Parameters:
Parameter | Type | Description |
---|---|---|
idOrName |
string | Id or name of process |
save ❓
Freeze a process list for automatic respawn
pm2()->save(bool $force = true): bool
Parameters:
Parameter | Type | Description |
---|---|---|
force |
bool | Force save list |
logOut ❓
Display all processes output logs
pm2()->logOut(string $idOrName = null, int $lines = 100): string
Parameters:
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): string
Parameters:
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(): bool
version ❓
Fetch installed pm2 version
pm2()->version(): string
install ❓
Install PM2 (Requirements: node
, npm
)
pm2()->install(string $version = 'latest'): false|string|null
Parameters:
Parameter | Type | Description |
---|---|---|
version |
string | Specific version |
Check if the PM2 is installed
pm2()->isInstall(bool $forceInstall = false, string $version = 'latest'): bool
Parameters:
Parameter | Type | Description |
---|---|---|
forceInstall |
bool | Install pm2 if is not installed |
version |
string | Specific version |
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.