Core AMPHP package supplying futures, cancellations, and coroutine helpers for PHP 8.1+. It builds on fibers and the Revolt event loop for concurrent I/O.
Overview
AMPHP is a family of event-driven PHP libraries; amphp/amp provides the base futures and cancellations used across the stack. Code can run concurrent work with Amp\async() and wait for results with Future::await() while keeping a style close to normal synchronous PHP.
Fibers give each coroutine its own call stack, scheduled cooperatively by Revolt rather than with generator boilerplate. Futures represent pending async results and support map, catch, and finally callbacks, plus combinators to await many tasks at once.
Cancellation objects let long operations respect timeouts, signals, or manual abort requests. Utilities include delay, signal trapping, and DeferredFuture for advanced producer patterns.
Install via Composer alongside revolt/event-loop. Related packages add HTTP clients and servers, sockets, databases, parallel workers, and streams on top of these primitives. PHP 8.1 or later is required; extensions are optional unless you need very high socket fan-out.
Key features
- Fiber-based coroutines
- Futures and await combinators
- Timeout and signal cancellation
- Amp\async concurrent tasks
- DeferredFuture producer API
- Revolt event-loop integration
- Non-blocking I/O oriented design
- Composable with other AMPHP packages
Use cases
- Concurrent HTTP requests in PHP
- Async database access patterns
- Building event-driven PHP services
- Overlapping I/O-bound workloads
- Library authors needing async primitives