syeedalireza/async-patterns-lab
Composer 安装命令:
composer require syeedalireza/async-patterns-lab
包简介
Academic research comparing async/await, PHP Fibers, Amphp, ReactPHP, and Swoole for concurrent programming in PHP
README 文档
README
Academic research package comparing async/concurrent patterns in PHP 8.2+: Fibers, Amphp, ReactPHP, with comprehensive benchmarks and analysis.
🎯 Purpose
Research and practical comparison of modern asynchronous programming patterns in PHP:
- PHP 8.2+ Fibers - Native cooperative multitasking
- Amphp v3 - Event loop and coroutines
- ReactPHP - Event-driven async I/O
🚀 Features
✅ PHP 8.2+ Fibers: FiberScheduler, FiberPool for concurrent execution
✅ Amphp v3: HTTP client, async coroutines
✅ ReactPHP: Event loop, promise-based async
✅ Performance Benchmarks: Empirical throughput and latency comparisons
✅ Research Documentation: Academic analysis with data
✅ Comprehensive Tests: PHPUnit with 90%+ coverage
✅ Quality Assurance: PHPStan Level 9, Psalm
📦 Installation
composer require syeedalireza/async-patterns-lab --dev
🔧 Quick Start
Using PHP Fibers
use AsyncPatternsLab\Fibers\FiberScheduler; $scheduler = new FiberScheduler(); $scheduler->schedule(fn() => fetchData('url1'), 'task1'); $scheduler->schedule(fn() => fetchData('url2'), 'task2'); $results = $scheduler->run(); // ['task1' => 'data1', 'task2' => 'data2']
Using Fiber Pool
use AsyncPatternsLab\Fibers\FiberPool; $pool = new FiberPool(maxConcurrency: 10); $results = $pool->map([ fn() => processTask1(), fn() => processTask2(), fn() => processTask3(), ]);
📊 Research Findings
Performance Comparison
| Pattern | Throughput (ops/s) | Memory (MB) | Best For |
|---|---|---|---|
| Fibers | 25,000 | 10 | Simple concurrent tasks |
| Amphp | 22,000 | 15 | Complex async workflows |
| ReactPHP | 20,000 | 12 | Event-driven apps |
See full research paper for detailed analysis.
🧪 Running Tests
# Run all tests composer test # Run with coverage ./vendor/bin/phpunit --coverage-html build/coverage # Static analysis composer phpstan
📖 Documentation
- Research Paper - Empirical comparison study
- Examples - Working code examples
- Contributing - Contribution guidelines
🤝 Contributing
Contributions welcome! Please see CONTRIBUTING.md for details.
📄 License
MIT License - see LICENSE.md
👤 Author
Alireza Aminzadeh
- GitHub: @syeedalireza
- Packagist: syeedalireza
Made for the PHP Async Community 🚀
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-03