What is PHP async programming with ReactPHP or Amp?
Answer
Traditional PHP is synchronous and blocking — each request runs in its own process, sequential I/O blocks execution. ReactPHP and Amp are event loop libraries that enable non-blocking I/O in PHP, similar to Node.js. An event loop watches for I/O events (socket ready, timer fired) and dispatches callbacks. ReactPHP uses Promises for async operations. Amp (v3) uses PHP 8.1 Fibers, allowing async code to be written in a synchronous style with $value = await($promise);. Use cases: HTTP servers handling thousands of concurrent connections, WebSocket servers, background job processors, and any I/O-heavy long-running PHP process where spawning a new process per connection is too expensive. Traditional PHP (FPM) is still better for most web apps due to simpler deployment.
Previous
What is Command Query Responsibility Segregation (CQRS) in PHP?
Next
What is Domain-Driven Design (DDD) in PHP?