syeedalireza / async-patterns-lab
Academic research comparing async/await, PHP Fibers, Amphp, ReactPHP, and Swoole for concurrent programming in PHP
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/syeedalireza/async-patterns-lab
Requires
- php: ^8.2
- ext-json: *
Requires (Dev)
- amphp/amp: ^3.0
- phpbench/phpbench: ^1.2
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^11.0
- react/event-loop: ^1.5
- react/promise: ^3.0
- vimeo/psalm: ^5.18
This package is not auto-updated.
Last update: 2026-02-04 05:02:55 UTC
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 ๐