https://github.com/diversen/background-job
Execute a background process with PHP
https://github.com/diversen/background-job
php-background-job
Last synced: 12 months ago
JSON representation
Execute a background process with PHP
- Host: GitHub
- URL: https://github.com/diversen/background-job
- Owner: diversen
- Created: 2016-05-18T07:47:54.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-16T13:03:14.000Z (about 10 years ago)
- Last Synced: 2024-11-13T19:11:52.185Z (over 1 year ago)
- Topics: php-background-job
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# background-job
PHP class that executes background jobs (in a very simple way).
Used this answer found on stackoverflow.com:
[http://stackoverflow.com/a/45966/464549](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
execute($command, "output.txt", "pid.txt");
// View pid
echo $bg->pid . "\n";
~~~
This executes `example.sh`:
~~~sh
#!/bin/bash
echo "Hi, I'm sleeping for 5 seconds..."
date
sleep 5
echo "all Done."
~~~