Fiberflow
๐ Revolutionary Laravel queue package leveraging PHP 8.1+ Fibers for 10-50x throughput improvement. Zero state pollution, async I/O, real-time dashboard.
Install / Use
/learn @virgilhawkins00/FiberflowREADME
FiberFlow
FiberFlow is a revolutionary Laravel queue worker that leverages PHP 8.1+ Fibers to enable true cooperative multitasking within a single process. Process 10,000 HTTP requests using only 100MB of RAM by suspending jobs during I/O operations instead of blocking the entire worker.
๐ The Problem
Traditional Laravel queue workers operate sequentially: one job at a time, one process per job. When a job makes an HTTP request that takes 2 seconds to respond, the worker process (consuming 30-50MB of RAM) sits idle, waiting. To scale, you spawn more processes, consuming gigabytes of memory.
FiberFlow changes the game.
โจ The Solution
Using PHP Fibers and the Revolt event loop, FiberFlow allows multiple jobs to run concurrently in a single worker process. When a job waits for I/O (HTTP requests, database queries with async drivers), the Fiber suspends, allowing other jobs to execute. The result:
- 70% reduction in infrastructure costs for I/O-heavy workloads
- 10x throughput for webhook processing, API integrations, and web scraping
- Zero configuration for basic usage - drop-in replacement for
queue:work - Pure PHP - no Swoole, no RoadRunner, no PECL extensions required
๐ Requirements
- PHP 8.2+ (Fibers introduced in 8.1, but 8.2+ recommended for stability)
- Laravel 11.x or 12.x
- Composer 2.0+
๐ฆ Installation
Install via Composer:
composer require fiberflow/fiberflow
Publish the configuration file (optional):
php artisan vendor:publish --tag=fiberflow-config
๐ฏ Quick Start
Replace your standard queue worker command:
# Before
php artisan queue:work
# After
php artisan fiber:work
That's it! Your jobs now run concurrently using Fibers.
๐ก Usage Example
Standard Job (Fiber-Safe)
use FiberFlow\Concerns\AsyncJob;
use FiberFlow\Facades\AsyncHttp;
class ProcessWebhook implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, AsyncJob;
public function handle()
{
// This suspends the Fiber, freeing the worker for other jobs
$response = AsyncHttp::post('https://api.stripe.com/v1/charges', [
'amount' => 2000,
'currency' => 'usd',
]);
// Execution resumes here when the response arrives
if ($response->successful()) {
// Process the response...
}
}
}
Configuration
// config/fiberflow.php
return [
'max_concurrency' => 50, // Maximum concurrent Fibers
'memory_limit' => 256, // MB per worker
'timeout' => 60, // Seconds per job
'dashboard' => true, // Enable TUI dashboard
];
๐จ TUI Dashboard
Launch the worker with real-time monitoring:
php artisan fiber:work --dashboard
Displays:
- Active vs. suspended Fibers
- Memory usage
- Jobs/second throughput
- Queue depth
โ ๏ธ Important Considerations
โ Ideal Use Cases
- Webhooks & Notifications: Sending thousands of HTTP requests to third-party APIs
- Web Scraping: Fetching data from multiple sources simultaneously
- API Proxying: Acting as an async middleware between services
- Email Campaigns: Sending bulk emails via external SMTP services
โ Not Recommended For
- CPU-Intensive Tasks: Image/video processing (blocks the event loop)
- Legacy Database Operations: Heavy Eloquent queries using blocking PDO (use async drivers or defer pattern)
- File System Operations: Large file reads/writes (blocking I/O)
๐ Container Isolation
FiberFlow uses Container Sandboxing to prevent state pollution between concurrent jobs. Each Fiber gets its own cloned container instance, ensuring:
- No shared singletons between jobs
- Isolated authentication state
- Safe multi-tenant operations
๐ Documentation
๐งช Testing
composer test
Run tests across PHP versions:
composer test:coverage
๐ค Contributing
Please see CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
๐ License
FiberFlow is open-sourced software licensed under the MIT license.
๐ Credits
- Built with Revolt PHP event loop
- Inspired by AMPHP async primitives
- Follows Spatie Package Standards
Made with โค๏ธ for the Laravel community
Related Skills
node-connect
350.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.1kQQBot ๅฏๅชไฝๆถๅ่ฝๅใไฝฟ็จ <qqmedia> ๆ ็ญพ๏ผ็ณป็ปๆ นๆฎๆไปถๆฉๅฑๅ่ชๅจ่ฏๅซ็ฑปๅ๏ผๅพ็/่ฏญ้ณ/่ง้ข/ๆไปถ๏ผใ
