Don't Wait, Generate!
summary
Generates resumable functions with yield to replace callbacks, using the AMPHP family plus the PHP-UV/libuv extension and an AMP HTTP server to multiplex requests inside a single long-running PHP process. Demo rewrites a raffle app: moves SMS sends to fire-and-forget promises, uses a MySQL connection pool (default 100), drops observed response time from ~18 ms to ~2.1 ms in warm runs, and reduces per-request bootstrapping and memory duplication. Trade-offs: single-process core use requires HTTP-level clustering for multi-core scaling.
AI-written summary · about
chapters (10)
- 0:00Introduction to generators
- 1:24What are generators and co-routines
- 3:44How generators work with yield
- 11:10Yield from and delegation
- 15:53Traditional PHP execution limits
- 20:17Event loops and async programming
- 27:32PHP with event loops and libuv
- 30:30Demo of amp framework
- 33:54Code walkthrough with amp
- 40:48Q&A session
