Run php in background.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
tests
README.md
nohup.php
test.php

README.md

PHPNohup - execute in background.

About

Running heavy duty function call when HTTP request comes to PHP poses challenge to send swift response.

These heavy duty function call can be run stateless at the background. But there is not easy with to achieve this.

PHPNohup is a utility to enable running such stateless script in background and checking its status using PID.

NOTE: It expects (nohup, ps) system command availability.

If you are on windows, gnuwin32 coreutils should help.

Usage

include_once 'nohup.php';

$cmd = 'du -csh ~/*';

$pid = PHPNohup::background($cmd);
echo (PHPNohup::check($pid)? 'running' : 'finished');

Credits

Thanks to Neil Saunders for sharing the code on the blog post.