Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jphp-group/jphp-process-ext
Process API for jphp
https://github.com/jphp-group/jphp-process-ext
Last synced: 7 days ago
JSON representation
Process API for jphp
- Host: GitHub
- URL: https://github.com/jphp-group/jphp-process-ext
- Owner: jphp-group
- License: apache-2.0
- Created: 2018-06-14T13:16:05.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-17T07:54:04.000Z (over 6 years ago)
- Last Synced: 2024-11-02T17:36:15.940Z (10 days ago)
- Language: Java
- Size: 9.77 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-jphp - jphp-process-ext - process API for jphp, more advanced and powerful! (Uncategorized / Uncategorized)
README
# jphp-process-ext
Process API for jphp, more advanced and powerful!**Features**:
+ Get process info (command, command line, args, etc).
+ Kill processes and children processes.
+ Get all running processes in OS.
+ Get children and parent processes.
+ Get processes by PID.**Requires**
+ Java 9+
+ JPPM### How to install
```bash
jppm add jphp-process-ext
```### How to use?
1. Get process handle of a process instance:
```php
use php\lang\Process;
use process\ProcessHandle;$process = new Process(['cmd', '/c', 'calc.exe']);
$processHandle = new ProcessHandle($process->start());echo "PID: ", $processHandle->pid(), "\n";
echo "Info: ", print_r($processHandle->info(), true), "\n";
```2. How to destroy process?
```php
$process = new Process(['cmd', '/c', 'calc.exe']);
$processHandle = new ProcessHandle($process->start());$success = $processHandle->destroy();
```3. How to get children processes?
```php
$processHandles = $processHandle->children();foreach ($processHandles as $handle) {
var_dump($handle->info());
}
```4. How to get all process handles?
```php
$allProcesses = ProcessHandle::allProcesses();
```5. How to get process handle by pid?
```php
$pid = 13894;
$processHandler = ProcessHandle::ofPid($pid);
```6. How to get process handle of current process?
```php
$processHandler = ProcessHandle::current();
```