Event-driven, non-blocking I/O for PHP: an event loop with async streams, DNS, sockets, HTTP and processes
open sourceMITfree
ReactPHP is a low-level library for event-driven programming in PHP. Its core is an event loop based on the reactor pattern, with promises and async/await-style coroutines on top, and components for streams, an async DNS resolver, TCP and UDP clients and servers, an HTTP client and server, child processes and caching. It suits network servers and clients with thousands of concurrent connections and other long-running PHP programs, needs no PHP extensions, and has a large ecosystem of third-party libraries built on it.
Problems it solves
- write a PHP server that handles thousands of concurrent connections
- run async HTTP requests in parallel from PHP
- build a long-running PHP daemon or websocket server without a separate web server
Features
- Event loop (reactor pattern)
- Promises and async/await-style coroutines
- Async streams, DNS resolver and TCP/UDP sockets
- HTTP client and server
- Child processes, caching and promise timers
- No PHP extensions required
Limitations
- Non-blocking by default: blocking I/O needs workers1
Alternatives
The same job
These do what ReactPHP does.
- Swoole Coroutine-based concurrency library for PHP