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.
1.0.6
2021-03-11 05:58 UTC
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."