├── CHANGELOG.md ├── src ├── Structure │ ├── AxmActions.php │ ├── AxmDynamic.php │ ├── AxmMonitor.php │ ├── AxmOptions.php │ ├── Monit.php │ ├── Process.php │ ├── Env.php │ └── Pm2Env.php ├── helpers.php └── Pm2.php ├── LICENSE.md ├── composer.json └── README.md /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `php-pm2` will be documented in this file. 4 | 5 | -------------------------------------------------------------------------------- /src/Structure/AxmActions.php: -------------------------------------------------------------------------------- 1 | data = $data; 13 | 14 | return $instance; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Structure/AxmDynamic.php: -------------------------------------------------------------------------------- 1 | data = $data; 13 | 14 | return $instance; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Structure/AxmMonitor.php: -------------------------------------------------------------------------------- 1 | data = $data; 13 | 14 | return $instance; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Structure/AxmOptions.php: -------------------------------------------------------------------------------- 1 | data = $data; 13 | 14 | return $instance; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Structure/Monit.php: -------------------------------------------------------------------------------- 1 | memory = $data['memory'] ?? null; 15 | $instance->cpu = $data['cpu'] ?? null; 16 | 17 | return $instance; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/helpers.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jalallinux/php-pm2", 3 | "description": "Manage pm2 process in php", 4 | "keywords": [ 5 | "jalallinux", 6 | "php-pm2" 7 | ], 8 | "homepage": "https://github.com/jalallinux/php-pm2", 9 | "license": "MIT", 10 | "authors": [ 11 | { 12 | "name": "JalalLinuX", 13 | "email": "smjjalalzadeh93@gmail.com", 14 | "role": "Developer" 15 | } 16 | ], 17 | "require": { 18 | "php": "^7.4|^8.0|^8.1|^8.2", 19 | "ext-json": "*" 20 | }, 21 | "require-dev": { 22 | "pestphp/pest": "^1.20", 23 | "spatie/ray": "^1.28" 24 | }, 25 | "autoload": { 26 | "psr-4": { 27 | "JalalLinuX\\Pm2\\": "src" 28 | }, 29 | "files": [ 30 | "src/helpers.php" 31 | ] 32 | }, 33 | "autoload-dev": { 34 | "psr-4": { 35 | "JalalLinuX\\Pm2\\Tests\\": "tests" 36 | } 37 | }, 38 | "scripts": { 39 | "test": "vendor/bin/pest", 40 | "test-coverage": "vendor/bin/pest --coverage" 41 | }, 42 | "config": { 43 | "sort-packages": true, 44 | "allow-plugins": { 45 | "phpstan/extension-installer": true, 46 | "pestphp/pest-plugin": true 47 | } 48 | }, 49 | "minimum-stability": "dev", 50 | "prefer-stable": true 51 | } 52 | -------------------------------------------------------------------------------- /src/Structure/Process.php: -------------------------------------------------------------------------------- 1 | pid = $data['pid'] ?? null; 21 | $instance->name = $data['name'] ?? null; 22 | $instance->pm2Env = ($data['pm2_env'] ?? null) !== null ? Pm2Env::fromJson($data['pm2_env']) : null; 23 | $instance->pmId = $data['pm_id'] ?? null; 24 | $instance->monit = ($data['monit'] ?? null) !== null ? Monit::fromJson($data['monit']) : null; 25 | 26 | return $instance; 27 | } 28 | 29 | public function start(array $options = []): bool 30 | { 31 | return pm2()->start($this->name, $options); 32 | } 33 | 34 | public function stop(): bool 35 | { 36 | return pm2()->stop($this->name); 37 | } 38 | 39 | public function restart(): bool 40 | { 41 | return pm2()->restart($this->name); 42 | } 43 | 44 | public function delete(): bool 45 | { 46 | return pm2()->delete($this->name); 47 | } 48 | 49 | public function logErr(int $lines = 100): string 50 | { 51 | return pm2()->logErr($this->name, $lines); 52 | } 53 | 54 | public function logOut(int $lines = 100): string 55 | { 56 | return pm2()->logOut($this->name, $lines); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Pm2.php: -------------------------------------------------------------------------------- 1 | prefix = $prefix; 14 | } 15 | 16 | /** 17 | * @return array 18 | */ 19 | public function list(string $sortField = 'name', bool $desc = true): array 20 | { 21 | return array_map(static fn ($rec) => Process::fromJson($rec), $this->json($sortField, $desc)); 22 | } 23 | 24 | public function link(string $publicKey, string $secretKey, string $machineName = null): bool 25 | { 26 | $result = $this->runCommand("link {$secretKey} {$publicKey} {$machineName} --update-env"); 27 | 28 | return strpos($result, 'activated!') !== false; 29 | } 30 | 31 | public function unlink(): bool 32 | { 33 | $result = $this->runCommand('link delete --update-env'); 34 | 35 | return strpos($result, 'ended') !== false; 36 | } 37 | 38 | public function start(string $command = null, array $options = []): bool 39 | { 40 | $options = $this->makeOptions($options); 41 | 42 | return ! is_null($this->runCommand('start'.(! is_null($command) ? " \"{$command}\" {$options} --update-env" : ''))); 43 | } 44 | 45 | public function findBy(string $key, string $value): ?Process 46 | { 47 | foreach ($this->list() as $item) { 48 | if ($item->{$key} == $value) { 49 | return $item; 50 | } 51 | } 52 | 53 | return null; 54 | } 55 | 56 | public function kill(): bool 57 | { 58 | return ! is_null($this->runCommand('kill --update-env')); 59 | } 60 | 61 | public function pid(string $name): ?int 62 | { 63 | foreach ($this->list() as $item) { 64 | if ($item->name == $name) { 65 | return intval($item->pid); 66 | } 67 | } 68 | 69 | return null; 70 | } 71 | 72 | public function flush(): bool 73 | { 74 | return ! is_null($this->runCommand('flush --update-env')); 75 | } 76 | 77 | /** 78 | * @return mixed 79 | */ 80 | public function update() 81 | { 82 | return $this->runCommand('update --update-env'); 83 | } 84 | 85 | public function stopAll(): bool 86 | { 87 | if (! is_null($this->runCommand('stop all --update-env'))) { 88 | $this->save(); 89 | 90 | return true; 91 | } 92 | 93 | return false; 94 | } 95 | 96 | public function restartAll(): bool 97 | { 98 | if (! is_null($this->runCommand('restart all --update-env'))) { 99 | $this->save(); 100 | 101 | return true; 102 | } 103 | 104 | return false; 105 | } 106 | 107 | public function deleteAll(): bool 108 | { 109 | if (! is_null($this->runCommand('del all --update-env'))) { 110 | $this->save(); 111 | 112 | return true; 113 | } 114 | 115 | return false; 116 | } 117 | 118 | public function stop(string $idOrName): bool 119 | { 120 | return ! is_null($this->runCommand("stop {$idOrName} --update-env")); 121 | } 122 | 123 | public function restart(string $idOrName): bool 124 | { 125 | return ! is_null($this->runCommand("restart {$idOrName} --update-env")); 126 | } 127 | 128 | public function delete(string $idOrName): bool 129 | { 130 | return ! is_null($this->runCommand("delete {$idOrName} --update-env")); 131 | } 132 | 133 | public function save(bool $force = true): bool 134 | { 135 | return ! is_null($this->runCommand('save'.($force ? ' --force' : ''))); 136 | } 137 | 138 | public function logOut(string $idOrName = null, int $lines = 100): string 139 | { 140 | return $this->runCommand('logs'.(! is_null($idOrName) ? " {$idOrName}" : '')." --lines={$lines} --nostream --raw --out"); 141 | } 142 | 143 | public function logErr(string $idOrName = null, int $lines = 100): string 144 | { 145 | return $this->runCommand('logs'.(! is_null($idOrName) ? " {$idOrName}" : '')." --lines={$lines} --nostream --raw --err"); 146 | } 147 | 148 | public function startup(): bool 149 | { 150 | $this->runCommand('startup --update-env'); 151 | 152 | return $this->save(); 153 | } 154 | 155 | public function version(): string 156 | { 157 | return trim($this->runCommand('--version')); 158 | } 159 | 160 | /** 161 | * @return false|string|null 162 | */ 163 | public function install(string $version = 'latest') 164 | { 165 | return shell_exec("npm install -g pm2@{$version}"); 166 | } 167 | 168 | public function isInstall(bool $forceInstall = false, string $version = 'latest'): bool 169 | { 170 | $isInstall = ! is_null($this->runCommand('--version')); 171 | if (! $isInstall && $forceInstall) { 172 | $this->install($version); 173 | 174 | return $this->isInstall(); 175 | } 176 | 177 | return $isInstall; 178 | } 179 | 180 | protected function makeOptions(array $options): string 181 | { 182 | return implode(' ', array_map(function ($k, $v) { 183 | return is_int($k) ? "--{$v}" : "--{$k}={$v}"; 184 | }, array_keys($options), $options)); 185 | } 186 | 187 | protected function json(string $sortField, bool $desc = true): array 188 | { 189 | return json_decode($this->runCommand("jlist --sort {$sortField}:".($desc ? 'desc' : 'asc')), true) ?? []; 190 | } 191 | 192 | protected function runCommand(string $command) 193 | { 194 | return shell_exec(trim("{$this->prefix} pm2 {$command}")); 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |

5 |
6 | 7 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/jalallinux/php-pm2.svg?style=flat-square)](https://packagist.org/packages/jalallinux/php-pm2) 8 | [![Tests](https://github.com/jalallinux/php-pm2/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/jalallinux/php-pm2/actions/workflows/run-tests.yml) 9 | [![Total Downloads](https://img.shields.io/packagist/dt/jalallinux/php-pm2.svg?style=flat-square)](https://packagist.org/packages/jalallinux/php-pm2) 10 | 11 | ## Use and Manage **PM2** in php 12 | 13 |
14 | 15 | ## Installation 16 | 17 | You can install the package via composer: 18 | 19 | ```bash 20 | composer require jalallinux/php-pm2 21 | ``` 22 | 23 | ## Usage 24 | 25 | ### Pm2 26 | 27 | * Full name: \JalalLinuX\Pm2\Pm2 28 | 29 | ### list [:question:](https://pm2.keymetrics.io/docs/usage/quick-start/#list-managed-applications) 30 | Fetch list all running applications 31 | ```php 32 | pm2()->list(string $sortField = 'name', bool $desc = true): array 33 | ``` 34 | 35 | **Parameters:** 36 | 37 | | Parameter | Type | Description | 38 | |-----------|------------|---------------------------------------------------------| 39 | | `sortField` | **string** | Sort field: `name, id, pid, memory, cpu, status, uptime` | 40 | | `desc` | **bool** | Sort order is descending | 41 | 42 | 43 | --- 44 | ### link [:question:]() 45 | Connect your server to your dashboard and start collecting metrics 46 | ```php 47 | pm2()->link(string $publicKey, string $secretKey, string|null $machineName = null): bool 48 | ``` 49 | 50 | **Parameters:** 51 | 52 | | Parameter | Type | Description | 53 | |-----------|-------------|-------------------------------| 54 | | `publicKey` | **string** | PM2 account `PUBLIC_KEY` | 55 | | `secretKey` | **string** | PM2 account `SECRET_KEY` | 56 | | `machineName` | **?string** | Machine name on the dashboard | 57 | 58 | --- 59 | ### unlink [:question:]() 60 | Disconnect your server from your metrics dashboard 61 | ```php 62 | pm2()->unlink(): bool 63 | ``` 64 | 65 | --- 66 | ### start [:question:](https://pm2.keymetrics.io/docs/usage/quick-start/#start-an-app) 67 | Start command with specifics options or start a `ecosystem.config.js` 68 | ```php 69 | pm2()->start(string $command = null, array $options = []): bool 70 | ``` 71 | 72 | **Parameters:** 73 | 74 | | Parameter | Type | Description | 75 | |-----------|------------|-------------| 76 | | `command` | **?string** | Command to run in pm2 | 77 | | `options` | **array** | Options to start pm2 command [Guide](https://pm2.keymetrics.io/docs/usage/quick-start/#start-an-app) like `['name' => 'process-1', 'no-autorestart']` | 78 | 79 | --- 80 | ### findBy [:question:](https://pm2.keymetrics.io/docs/usage/process-management/#showing-application-metadata) 81 | Find specific process 82 | ```php 83 | pm2()->findBy(string $key, string $value): \JalalLinuX\Pm2\Structure\Process|null 84 | ``` 85 | 86 | **Parameters:** 87 | 88 | | Parameter | Type | Description | 89 | |-----------|------|-------------| 90 | | `key` | **string** | Key of property to find process | 91 | | `value` | **string** | Value of key | 92 | 93 | --- 94 | ### kill 95 | kill daemon 96 | ```php 97 | pm2()->kill(): bool 98 | ``` 99 | 100 | --- 101 | ### pid 102 | Fetch pid of specific process 103 | ```php 104 | pm2()->pid(string $name): int|null 105 | ``` 106 | 107 | **Parameters:** 108 | 109 | | Parameter | Type | Description | 110 | |-----------|------|-------------| 111 | | `name` | **string** | Name of process | 112 | 113 | --- 114 | ### flush [:question:](https://pm2.keymetrics.io/docs/usage/log-management/#flushing-logs) 115 | Empty all log files 116 | ```php 117 | pm2()->flush(): bool 118 | ``` 119 | 120 | --- 121 | ### update [:question:](https://pm2.keymetrics.io/docs/usage/update-pm2/#process-to-update-pm2) 122 | Update in memory pm2 123 | ```php 124 | pm2()->update(): mixed 125 | ``` 126 | 127 | --- 128 | ### stopAll [:question:](https://pm2.keymetrics.io/docs/usage/process-management/#stop) 129 | Stop all processes 130 | ```php 131 | pm2()->stopAll(): bool 132 | ``` 133 | 134 | --- 135 | ### restartAll [:question:](https://pm2.keymetrics.io/docs/usage/process-management/#restart) 136 | Restart all processes 137 | ```php 138 | pm2()->restartAll(): bool 139 | ``` 140 | 141 | --- 142 | ### deleteAll [:question:](https://pm2.keymetrics.io/docs/usage/process-management/#delete) 143 | Will stop and delete all processes from pm2 list 144 | ```php 145 | pm2()->deleteAll(): bool 146 | ``` 147 | 148 | --- 149 | ### stop [:question:](https://pm2.keymetrics.io/docs/usage/process-management/#stop) 150 | Stop specific process 151 | ```php 152 | pm2()->stop(string $idOrName): bool 153 | ``` 154 | 155 | **Parameters:** 156 | 157 | | Parameter | Type | Description | 158 | |-----------|------|-------------| 159 | | `idOrName` | **string** | Id or name of process| 160 | 161 | --- 162 | ### restart [:question:](https://pm2.keymetrics.io/docs/usage/process-management/#restart) 163 | Restart specific process 164 | ```php 165 | pm2()->restart(string $idOrName): bool 166 | ``` 167 | 168 | **Parameters:** 169 | 170 | | Parameter | Type | Description | 171 | |-----------|------|-------------| 172 | | `idOrName` | **string** | Id or name of process| 173 | 174 | --- 175 | ### delete [:question:](https://pm2.keymetrics.io/docs/usage/process-management/#delete) 176 | Delete specific process 177 | ```php 178 | pm2()->delete(string $idOrName): bool 179 | ``` 180 | 181 | **Parameters:** 182 | 183 | | Parameter | Type | Description | 184 | |-----------|------|-------------| 185 | | `idOrName` | **string** | Id or name of process | 186 | 187 | --- 188 | ### save [:question:](https://pm2.keymetrics.io/docs/usage/startup/#saving-the-app-list-to-be-restored-at-reboot) 189 | Freeze a process list for automatic respawn 190 | ```php 191 | pm2()->save(bool $force = true): bool 192 | ``` 193 | 194 | **Parameters:** 195 | 196 | | Parameter | Type | Description | 197 | |-----------|------|-------------| 198 | | `force` | **bool** | Force save list | 199 | 200 | --- 201 | ### logOut [:question:](https://pm2.keymetrics.io/docs/usage/log-management/#log-views) 202 | Display all processes output logs 203 | ```php 204 | pm2()->logOut(string $idOrName = null, int $lines = 100): string 205 | ``` 206 | 207 | **Parameters:** 208 | 209 | | Parameter | Type | Description | 210 | |-----------|------|-------------| 211 | | `idOrName` | **?string** | Id or name of process | 212 | | `lines` | **int** | To dig in older logs | 213 | 214 | --- 215 | ### logErr [:question:](https://pm2.keymetrics.io/docs/usage/log-management/#log-views) 216 | Display all processes error logs 217 | ```php 218 | pm2()->logErr(string $idOrName = null, int $lines = 100): string 219 | ``` 220 | 221 | **Parameters:** 222 | 223 | | Parameter | Type | Description | 224 | |-----------|------|-------------| 225 | | `idOrName` | **?string** | Id or name of process | 226 | | `lines` | **int** | To dig in older logs | 227 | 228 | --- 229 | ### startup [:question:](https://pm2.keymetrics.io/docs/usage/quick-start/#setup-startup-script) 230 | Generate an active startup script 231 | ```php 232 | pm2()->startup(): bool 233 | ``` 234 | 235 | --- 236 | ### version [:question:]() 237 | Fetch installed pm2 version 238 | ```php 239 | pm2()->version(): string 240 | ``` 241 | 242 | --- 243 | ### install [:question:](https://pm2.keymetrics.io/docs/usage/update-pm2/#process-to-update-pm2) 244 | Install **PM2** (Requirements: `node`, `npm`) 245 | ```php 246 | pm2()->install(string $version = 'latest'): false|string|null 247 | ``` 248 | 249 | **Parameters:** 250 | 251 | | Parameter | Type | Description | 252 | |-----------|------|-------------| 253 | | `version` | **string** | Specific version | 254 | 255 | --- 256 | ### isInstall 257 | Check if the **PM2** is installed 258 | ```php 259 | pm2()->isInstall(bool $forceInstall = false, string $version = 'latest'): bool 260 | ``` 261 | 262 | **Parameters:** 263 | 264 | | Parameter | Type | Description | 265 | |-----------|------|-------------| 266 | | `forceInstall` | **bool** | Install pm2 if is not installed | 267 | | `version` | **string** | Specific version | 268 | 269 | 270 | ## Testing 271 | 272 | ```bash 273 | composer test 274 | ``` 275 | 276 | ## Changelog 277 | 278 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 279 | 280 | ## Credits 281 | 282 | - [JalalLinuX](https://github.com/jalallinux) 283 | - [All Contributors](../../contributors) 284 | 285 | ## License 286 | 287 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 288 | -------------------------------------------------------------------------------- /src/Structure/Env.php: -------------------------------------------------------------------------------- 1 | uniqueId = $data['unique_id'] ?? null; 169 | $instance->pm2Home = $data['PM2_HOME'] ?? null; 170 | $instance->shell = $data['SHELL'] ?? null; 171 | $instance->sessionManager = $data['SESSION_MANAGER'] ?? null; 172 | $instance->qtAccessibility = $data['QT_ACCESSIBILITY'] ?? null; 173 | $instance->snapRevision = $data['SNAP_REVISION'] ?? null; 174 | $instance->xdgConfigDirs = $data['XDG_CONFIG_DIRS'] ?? null; 175 | $instance->xdgMenuPrefix = $data['XDG_MENU_PREFIX'] ?? null; 176 | $instance->gnomeDesktopSessionId = $data['GNOME_DESKTOP_SESSION_ID'] ?? null; 177 | $instance->snapRealHome = $data['SNAP_REAL_HOME'] ?? null; 178 | $instance->terminalEmulator = $data['TERMINAL_EMULATOR'] ?? null; 179 | $instance->snapUserCommon = $data['SNAP_USER_COMMON'] ?? null; 180 | $instance->lcAddress = $data['LC_ADDRESS'] ?? null; 181 | $instance->gnomeShellSessionMode = $data['GNOME_SHELL_SESSION_MODE'] ?? null; 182 | $instance->lcName = $data['LC_NAME'] ?? null; 183 | $instance->sshAuthSock = $data['SSH_AUTH_SOCK'] ?? null; 184 | $instance->termSessionId = $data['TERM_SESSION_ID'] ?? null; 185 | $instance->snapInstanceKey = $data['SNAP_INSTANCE_KEY'] ?? null; 186 | $instance->xmodifiers = $data['XMODIFIERS'] ?? null; 187 | $instance->desktopSession = $data['DESKTOP_SESSION'] ?? null; 188 | $instance->lcMonetary = $data['LC_MONETARY'] ?? null; 189 | $instance->sshAgentPid = $data['SSH_AGENT_PID'] ?? null; 190 | $instance->bamfDesktopFileHint = $data['BAMF_DESKTOP_FILE_HINT'] ?? null; 191 | $instance->gtkModules = $data['GTK_MODULES'] ?? null; 192 | $instance->pwd = $data['PWD'] ?? null; 193 | $instance->xdgSessionDesktop = $data['XDG_SESSION_DESKTOP'] ?? null; 194 | $instance->logname = $data['LOGNAME'] ?? null; 195 | $instance->xdgSessionType = $data['XDG_SESSION_TYPE'] ?? null; 196 | $instance->gpgAgentInfo = $data['GPG_AGENT_INFO'] ?? null; 197 | $instance->xauthority = $data['XAUTHORITY'] ?? null; 198 | $instance->desktopStartupId = $data['DESKTOP_STARTUP_ID'] ?? null; 199 | $instance->snapContext = $data['SNAP_CONTEXT'] ?? null; 200 | $instance->gjsDebugTopics = $data['GJS_DEBUG_TOPICS'] ?? null; 201 | $instance->windowpath = $data['WINDOWPATH'] ?? null; 202 | $instance->home = $data['HOME'] ?? null; 203 | $instance->username = $data['USERNAME'] ?? null; 204 | $instance->imConfigPhase = $data['IM_CONFIG_PHASE'] ?? null; 205 | $instance->lang = $data['LANG'] ?? null; 206 | $instance->lcPaper = $data['LC_PAPER'] ?? null; 207 | $instance->lsColors = $data['LS_COLORS'] ?? null; 208 | $instance->xdgCurrentDesktop = $data['XDG_CURRENT_DESKTOP'] ?? null; 209 | $instance->snapArch = $data['SNAP_ARCH'] ?? null; 210 | $instance->snapInstanceName = $data['SNAP_INSTANCE_NAME'] ?? null; 211 | $instance->snapUserData = $data['SNAP_USER_DATA'] ?? null; 212 | $instance->compWordbreaks = $data['COMP_WORDBREAKS'] ?? null; 213 | $instance->invocationId = $data['INVOCATION_ID'] ?? null; 214 | $instance->managerpid = $data['MANAGERPID'] ?? null; 215 | $instance->snapReexec = $data['SNAP_REEXEC'] ?? null; 216 | $instance->gjsDebugOutput = $data['GJS_DEBUG_OUTPUT'] ?? null; 217 | $instance->lessclose = $data['LESSCLOSE'] ?? null; 218 | $instance->xdgSessionClass = $data['XDG_SESSION_CLASS'] ?? null; 219 | $instance->term = $data['TERM'] ?? null; 220 | $instance->lcIdentification = $data['LC_IDENTIFICATION'] ?? null; 221 | $instance->lessopen = $data['LESSOPEN'] ?? null; 222 | $instance->user = $data['USER'] ?? null; 223 | $instance->snap = $data['SNAP'] ?? null; 224 | $instance->snapCommon = $data['SNAP_COMMON'] ?? null; 225 | $instance->snapVersion = $data['SNAP_VERSION'] ?? null; 226 | $instance->display = $data['DISPLAY'] ?? null; 227 | $instance->shlvl = $data['SHLVL'] ?? null; 228 | $instance->snapLibraryPath = $data['SNAP_LIBRARY_PATH'] ?? null; 229 | $instance->snapCookie = $data['SNAP_COOKIE'] ?? null; 230 | $instance->lcTelephone = $data['LC_TELEPHONE'] ?? null; 231 | $instance->qtImModule = $data['QT_IM_MODULE'] ?? null; 232 | $instance->lcMeasurement = $data['LC_MEASUREMENT'] ?? null; 233 | $instance->snapData = $data['SNAP_DATA'] ?? null; 234 | $instance->xdgRuntimeDir = $data['XDG_RUNTIME_DIR'] ?? null; 235 | $instance->lcTime = $data['LC_TIME'] ?? null; 236 | $instance->snapName = $data['SNAP_NAME'] ?? null; 237 | $instance->journalStream = $data['JOURNAL_STREAM'] ?? null; 238 | $instance->xdgDataDirs = $data['XDG_DATA_DIRS'] ?? null; 239 | $instance->path = $data['PATH'] ?? null; 240 | $instance->gdmsession = $data['GDMSESSION'] ?? null; 241 | $instance->dbusSessionBusAddress = $data['DBUS_SESSION_BUS_ADDRESS'] ?? null; 242 | $instance->gioLaunchedDesktopFilePid = $data['GIO_LAUNCHED_DESKTOP_FILE_PID'] ?? null; 243 | $instance->gioLaunchedDesktopFile = $data['GIO_LAUNCHED_DESKTOP_FILE'] ?? null; 244 | $instance->lcNumeric = $data['LC_NUMERIC'] ?? null; 245 | $instance->_ = $data['_'] ?? null; 246 | $instance->pm2Usage = $data['PM2_USAGE'] ?? null; 247 | 248 | return $instance; 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /src/Structure/Pm2Env.php: -------------------------------------------------------------------------------- 1 | exitCode = $data['exit_code'] ?? null; 250 | $instance->versioning = $data['versioning'] ?? null; 251 | $instance->version = $data['version'] ?? null; 252 | $instance->unstableRestarts = $data['unstable_restarts'] ?? null; 253 | $instance->restartTime = $data['restart_time'] ?? null; 254 | $instance->pmId = $data['pm_id'] ?? null; 255 | $instance->createdAt = $data['created_at'] ?? null; 256 | $instance->axmDynamic = ($data['axm_dynamic'] ?? null) !== null ? AxmDynamic::fromJson($data['axm_dynamic']) : null; 257 | $instance->axmOptions = ($data['axm_options'] ?? null) !== null ? AxmOptions::fromJson($data['axm_options']) : null; 258 | $instance->axmMonitor = ($data['axm_monitor'] ?? null) !== null ? AxmMonitor::fromJson($data['axm_monitor']) : null; 259 | $instance->axmActions = $data['axm_actions'] ?? null; 260 | $instance->pmUptime = $data['pm_uptime'] ?? null; 261 | $instance->status = $data['status'] ?? null; 262 | $instance->uniqueId = $data['unique_id'] ?? null; 263 | $instance->pm2Home = $data['PM2_HOME'] ?? null; 264 | $instance->shell = $data['SHELL'] ?? null; 265 | $instance->sessionManager = $data['SESSION_MANAGER'] ?? null; 266 | $instance->qtAccessibility = $data['QT_ACCESSIBILITY'] ?? null; 267 | $instance->snapRevision = $data['SNAP_REVISION'] ?? null; 268 | $instance->xdgConfigDirs = $data['XDG_CONFIG_DIRS'] ?? null; 269 | $instance->xdgMenuPrefix = $data['XDG_MENU_PREFIX'] ?? null; 270 | $instance->gnomeDesktopSessionId = $data['GNOME_DESKTOP_SESSION_ID'] ?? null; 271 | $instance->snapRealHome = $data['SNAP_REAL_HOME'] ?? null; 272 | $instance->terminalEmulator = $data['TERMINAL_EMULATOR'] ?? null; 273 | $instance->snapUserCommon = $data['SNAP_USER_COMMON'] ?? null; 274 | $instance->lcAddress = $data['LC_ADDRESS'] ?? null; 275 | $instance->gnomeShellSessionMode = $data['GNOME_SHELL_SESSION_MODE'] ?? null; 276 | $instance->lcName = $data['LC_NAME'] ?? null; 277 | $instance->sshAuthSock = $data['SSH_AUTH_SOCK'] ?? null; 278 | $instance->termSessionId = $data['TERM_SESSION_ID'] ?? null; 279 | $instance->snapInstanceKey = $data['SNAP_INSTANCE_KEY'] ?? null; 280 | $instance->xmodifiers = $data['XMODIFIERS'] ?? null; 281 | $instance->desktopSession = $data['DESKTOP_SESSION'] ?? null; 282 | $instance->lcMonetary = $data['LC_MONETARY'] ?? null; 283 | $instance->sshAgentPid = $data['SSH_AGENT_PID'] ?? null; 284 | $instance->bamfDesktopFileHint = $data['BAMF_DESKTOP_FILE_HINT'] ?? null; 285 | $instance->gtkModules = $data['GTK_MODULES'] ?? null; 286 | $instance->pwd = $data['PWD'] ?? null; 287 | $instance->xdgSessionDesktop = $data['XDG_SESSION_DESKTOP'] ?? null; 288 | $instance->logname = $data['LOGNAME'] ?? null; 289 | $instance->xdgSessionType = $data['XDG_SESSION_TYPE'] ?? null; 290 | $instance->gpgAgentInfo = $data['GPG_AGENT_INFO'] ?? null; 291 | $instance->xauthority = $data['XAUTHORITY'] ?? null; 292 | $instance->desktopStartupId = $data['DESKTOP_STARTUP_ID'] ?? null; 293 | $instance->snapContext = $data['SNAP_CONTEXT'] ?? null; 294 | $instance->gjsDebugTopics = $data['GJS_DEBUG_TOPICS'] ?? null; 295 | $instance->windowpath = $data['WINDOWPATH'] ?? null; 296 | $instance->home = $data['HOME'] ?? null; 297 | $instance->username = $data['USERNAME'] ?? null; 298 | $instance->imConfigPhase = $data['IM_CONFIG_PHASE'] ?? null; 299 | $instance->lang = $data['LANG'] ?? null; 300 | $instance->lcPaper = $data['LC_PAPER'] ?? null; 301 | $instance->lsColors = $data['LS_COLORS'] ?? null; 302 | $instance->xdgCurrentDesktop = $data['XDG_CURRENT_DESKTOP'] ?? null; 303 | $instance->snapArch = $data['SNAP_ARCH'] ?? null; 304 | $instance->snapInstanceName = $data['SNAP_INSTANCE_NAME'] ?? null; 305 | $instance->snapUserData = $data['SNAP_USER_DATA'] ?? null; 306 | $instance->compWordbreaks = $data['COMP_WORDBREAKS'] ?? null; 307 | $instance->invocationId = $data['INVOCATION_ID'] ?? null; 308 | $instance->managerpid = $data['MANAGERPID'] ?? null; 309 | $instance->snapReexec = $data['SNAP_REEXEC'] ?? null; 310 | $instance->gjsDebugOutput = $data['GJS_DEBUG_OUTPUT'] ?? null; 311 | $instance->lessclose = $data['LESSCLOSE'] ?? null; 312 | $instance->xdgSessionClass = $data['XDG_SESSION_CLASS'] ?? null; 313 | $instance->term = $data['TERM'] ?? null; 314 | $instance->lcIdentification = $data['LC_IDENTIFICATION'] ?? null; 315 | $instance->lessopen = $data['LESSOPEN'] ?? null; 316 | $instance->user = $data['USER'] ?? null; 317 | $instance->snap = $data['SNAP'] ?? null; 318 | $instance->snapCommon = $data['SNAP_COMMON'] ?? null; 319 | $instance->snapVersion = $data['SNAP_VERSION'] ?? null; 320 | $instance->display = $data['DISPLAY'] ?? null; 321 | $instance->shlvl = $data['SHLVL'] ?? null; 322 | $instance->snapLibraryPath = $data['SNAP_LIBRARY_PATH'] ?? null; 323 | $instance->snapCookie = $data['SNAP_COOKIE'] ?? null; 324 | $instance->lcTelephone = $data['LC_TELEPHONE'] ?? null; 325 | $instance->qtImModule = $data['QT_IM_MODULE'] ?? null; 326 | $instance->lcMeasurement = $data['LC_MEASUREMENT'] ?? null; 327 | $instance->snapData = $data['SNAP_DATA'] ?? null; 328 | $instance->xdgRuntimeDir = $data['XDG_RUNTIME_DIR'] ?? null; 329 | $instance->lcTime = $data['LC_TIME'] ?? null; 330 | $instance->snapName = $data['SNAP_NAME'] ?? null; 331 | $instance->journalStream = $data['JOURNAL_STREAM'] ?? null; 332 | $instance->xdgDataDirs = $data['XDG_DATA_DIRS'] ?? null; 333 | $instance->path = $data['PATH'] ?? null; 334 | $instance->gdmsession = $data['GDMSESSION'] ?? null; 335 | $instance->dbusSessionBusAddress = $data['DBUS_SESSION_BUS_ADDRESS'] ?? null; 336 | $instance->gioLaunchedDesktopFilePid = $data['GIO_LAUNCHED_DESKTOP_FILE_PID'] ?? null; 337 | $instance->gioLaunchedDesktopFile = $data['GIO_LAUNCHED_DESKTOP_FILE'] ?? null; 338 | $instance->lcNumeric = $data['LC_NUMERIC'] ?? null; 339 | $instance->_ = $data['_'] ?? null; 340 | $instance->pm2Usage = $data['PM2_USAGE'] ?? null; 341 | $instance->nodeAppInstance = $data['NODE_APP_INSTANCE'] ?? null; 342 | $instance->vizionRunning = $data['vizion_running'] ?? null; 343 | $instance->kmLink = $data['km_link'] ?? null; 344 | $instance->pmPidPath = $data['pm_pid_path'] ?? null; 345 | $instance->pmErrLogPath = $data['pm_err_log_path'] ?? null; 346 | $instance->pmOutLogPath = $data['pm_out_log_path'] ?? null; 347 | $instance->instances = $data['instances'] ?? null; 348 | $instance->execMode = $data['exec_mode'] ?? null; 349 | $instance->execInterpreter = $data['exec_interpreter'] ?? null; 350 | $instance->pmCwd = $data['pm_cwd'] ?? null; 351 | $instance->pmExecPath = $data['pm_exec_path'] ?? null; 352 | $instance->nodeArgs = $data['node_args'] ?? null; 353 | $instance->name = $data['name'] ?? null; 354 | $instance->filterEnv = $data['filter_env'] ?? null; 355 | $instance->namespace = $data['namespace'] ?? null; 356 | $instance->args = $data['args'] ?? null; 357 | $instance->env = ($data['env'] ?? null) !== null ? Env::fromJson($data['env']) : null; 358 | $instance->mergeLogs = $data['merge_logs'] ?? null; 359 | $instance->vizion = $data['vizion'] ?? null; 360 | $instance->autorestart = $data['autorestart'] ?? null; 361 | $instance->watch = $data['watch'] ?? null; 362 | $instance->instanceVar = $data['instance_var'] ?? null; 363 | $instance->pmx = $data['pmx'] ?? null; 364 | $instance->automation = $data['automation'] ?? null; 365 | $instance->treekill = $data['treekill'] ?? null; 366 | $instance->windowsHide = $data['windowsHide'] ?? null; 367 | $instance->killRetryTime = $data['kill_retry_time'] ?? null; 368 | 369 | return $instance; 370 | } 371 | } 372 | --------------------------------------------------------------------------------