cocur/background-process
Run shell commands as detached background processes from PHP so they keep running after the request/script ends. Start jobs, optionally get PID, poll if running, and stop them (Unix). Basic Windows support for launching only.
ffmpeg, imagemagick).*"This package lets us handle time-consuming tasks—like generating reports or processing uploads—in the background without slowing down our application or requiring expensive infrastructure. It’s a lightweight, self-managed solution for scenarios where a full queue system is overkill. Think of it as ‘set it and forget it’ for PHP background tasks.
Why now?
Example: Instead of making users wait 30 seconds for a video to process, we’ll offload it to the background and return a ‘processing’ response instantly. The package handles this in two lines of code with no external dependencies."*
*"Pros:
$process->run()—no queue setup.Cons:
When to Use:
ffmpeg, curl, custom scripts).exec() calls in web requests.Alternatives:
Example Integration:
// In a Laravel controller or Artisan command:
$process = new \Cocur\BackgroundProcess('php artisan optimize:images storage/path');
$process->run();
// Store PID in DB for later cleanup if needed.
DB::table('background_jobs')->insert([
'pid' => $process->getPid(),
'command' => 'optimize:images',
'created_at' => now(),
]);
Risks to Mitigate:
Next Steps:
How can I help you explore Laravel packages today?