spatie/async
Run PHP tasks in parallel with a simple Pool API built on PCNTL. Add closures, handle results via then/catch, and wait for completion. Ideal for speeding up batch jobs, CPU-heavy work, and IO-bound processing with multiple processes.
pcntl wrappers or queue systems like Laravel Queues for non-I/O-bound tasks).Adopt when:
popen or queues).spatie/async in a custom job class).Look elsewhere if:
reactphp or swoole).For Executives: "This package lets us run CPU-heavy tasks in parallel—like crunching large datasets or processing videos—without adding servers. For example, if our ‘Generate Reports’ endpoint takes 5 seconds, we can cut that to 1 second by splitting the work across 5 processes. It’s like adding horsepower to our app without buying a bigger engine. Best for batch jobs, real-time data processing, or offloading work from user-facing requests."
For Engineers:
*"Spatie/Async is a lightweight wrapper for PHP’s pcntl extension that lets you fire-and-forget CPU-bound tasks in parallel. Key benefits:
Async::run(fn() => heavyComputation())—no queues or workers to manage.For Developers:
*"Need to speed up a slow script? Wrap it in Async::parallel() and let PHP handle the rest. Example:
$results = Async::parallel([
fn() => processUserData($user1),
fn() => processUserData($user2),
]);
How can I help you explore Laravel packages today?