maxwellhealth / background-process
A small PHP library to run background processes
Installs: 25 604
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 10
Forks: 0
Open Issues: 0
Requires (Dev)
- phpunit/phpunit: 4.8.*
This package is not auto-updated.
Last update: 2025-02-01 21:57:25 UTC
README
A small PHP library to run background processes.
Basic Usage
From example.php:
<?php require_once 'vendor/autoload.php'; use BackgroundProcess\Process; $pid = (new Process()) ->withCommand('php tests/test-task.php') ->run(); echo 'Started process with PID ' . $pid . PHP_EOL;
user@host:~/background-process$ php example.php
Started process with PID 2129
user@host:~/background-process$ ps
PID TTY TIME CMD
1706 ttys001 0:00.03 -bash
2129 ttys001 0:00.03 php tests/test-task.php
user@host:~/background-process$
Capturing stdout and stderr
$pid = (new Process()) ->withCommand('php tests/test-task.php') ->withStdoutFile('/tmp/stdout.log') ->withStderrFile('/tmp/stderr.log') ->run();
Writing to stdin
$pid = (new Process()) ->withCommand('php tests/test-task.php') ->withInput('hello world!') ->run();