jadedaniel / background-job
Simple background job creator
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Installs: 609
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
pkg:composer/jadedaniel/background-job
Requires
- php: >=8.0
Requires (Dev)
- phpunit/phpunit: ^8
README
PHP class that executes background jobs (in a very simple way).
Used this answer found on stackoverflow.com:
http://stackoverflow.com/a/45966/464549
You will need unix platform for this to work
Install
composer require diversen/background-job
Usage
cd background-job && php example.php
example.php:
<?php include_once "bgJob.php"; // Only used if autoloader is not enabled use diversen\bgJob; $bg = new bgJob(); $command = "./example.sh"; $bg->execute($command, "output.txt", "pid.txt"); // View pid echo $bg->pid . "\n";
This executes example.sh:
#!/bin/bash echo "Hi, I'm sleeping for 5 seconds..." date sleep 5 echo "all Done."