A non-blocking concurrency framework for PHP using fibers to write asynchronous code like synchronous code.
amphp/amp is a non-blocking concurrency framework for PHP applications that provides futures and cancellations as core primitives. It leverages PHP 8.1+ fibers to enable developers to write asynchronous code with synchronous-like syntax, solving the "color of your function" problem associated with earlier callback or generator-based approaches.
PHP developers building applications that require concurrent I/O operations, such as HTTP clients, servers, database access, or socket programming, who want to avoid blocking execution and improve performance.
Developers choose amphp/amp because it offers a modern, fiber-based approach to concurrency that eliminates callback complexity and generator boilerplate. Its integration with the Revolt event loop and comprehensive future/cancellation APIs provide a robust foundation for building scalable, non-blocking PHP applications.
A non-blocking concurrency framework for PHP applications. 🐘
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Leverages PHP 8.1+ fibers to write asynchronous code with synchronous-like syntax, eliminating callback hell and generator boilerplate, as emphasized in the motivation section.
Provides Future objects with methods like await(), map(), and catch(), enabling elegant error handling and chaining without nested callbacks.
Includes Timeout, Signal, and Deferred cancellations for fine-grained control over long-running operations, supporting timeouts and manual cancellation.
Offers utilities like awaitAll() and awaitAny() to coordinate multiple futures efficiently, ideal for concurrent I/O tasks such as HTTP requests.
Any blocking I/O function halts the entire process, requiring careful avoidance and reliance on non-blocking libraries, which can be a migration challenge for legacy code.
Heavily relies on the Revolt event loop and compatible AMPHP packages; limited third-party library support compared to synchronous PHP ecosystems.
Fibers are cooperatively scheduled, so a single coroutine that blocks or runs long can stall the entire application, demanding disciplined coding practices.