PHP Concurrency

Handling concurrency and non-blocking I/O in modern PHP.

majiayu000 ec0cef9 2 files · 1.8 KB Updated 567 repo stars

File contents

PHP Concurrency

Priority: P2 (MEDIUM)

Structure

src/
└── Async/
    ├── Schedulers/
    └── Clients/

Implementation Guidelines

  • Fibers: Use Fiber for low-level cooperative multitasking (8.1+).
  • Yield Control: Apply Fiber::suspend() to yield within Fibers.
  • I/O Bound: Target I/O tasks only; avoid for CPU intensive work.
  • Frameworks: Prefer Amp or ReactPHP for complex events.
  • Self-Contained: Ensure Fibers manage their own state/exceptions.
  • Incremental: Refactor single bottlenecks before full async.

Anti-Patterns

  • Implicit Flows: No Deep Suspend: Keep Fiber logic traceable.
  • Internal Blocking: No Blocking I/O: Don't block inside Fibers.
  • Custom Schedulers: No DIY Schedulers: Use proven async libs.

References

  • Fiber Implementation Guide

majiayu000/claude-skill-registry-data/tree/main/development/concurrency-hoangnguyen0403-agent-skills-standar commit ec0cef9201

Frequently asked questions

npx skillmds add majiayu000/php-concurrency