An open API service indexing awesome lists of open source software.

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

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."
~~~