enqueue/gearman
Gearman transport for Enqueue: send and consume queue messages via a Gearman broker using Enqueue’s queue specification. Part of the php-enqueue ecosystem with docs, support chat, and CI-tested releases.
Connection and Context objects. Reduces coupling to Gearman’s native API.enqueue/laravel), which may introduce indirection but ensures consistency with other Enqueue transports (e.g., Redis, RabbitMQ).config/queue.php:
'gearman' => [
'driver' => 'enqueue',
'transport' => 'gearman',
'host' => env('GEARMAN_HOST', 'localhost'),
'port' => env('GEARMAN_PORT', 4730),
'timeout' => 5.0,
],
Producer:
$producer = app(\Enqueue\Client\Producer::class);
$producer->send(new ProcessVideoJob(), new \Enqueue\Client\Message());
enqueue/laravel → enqueue/gearman → Gearman Server.
Risk: Breaks if any link fails (e.g., Gearman server down, Enqueue version mismatch).| Risk | Impact | Mitigation |
|---|---|---|
| Deprecated Package | No updates since 2017; potential security/compatibility issues. | Fork the repo or switch to enqueue/redis for active maintenance. |
| Gearman Ecosystem Obsolescence | Gearman is less performant than modern alternatives (e.g., Redis). | Benchmark against enqueue/redis; justify Gearman’s use case (e.g., legacy). |
| Laravel Plugin Gaps | Missing native support for Laravel-specific features (e.g., Queue::later()). |
Implement custom logic or use Enqueue’s delay extension. |
| Error Handling | Limited visibility into worker failures (e.g., crashed Gearman processes). | Integrate with Laravel’s FailedJob events or use a monitoring sidecar. |
| Scaling Complexity | Gearman’s worker affinity may require manual load balancing. | Use multiple Gearman servers with consistent hashing or a proxy (e.g., HAProxy). |
enqueue/gearman if issues arise?gearmand) and workers must be externally managed (not part of Laravel’s queue system).gearman-worker processes on servers.enqueue/gearman with a subset of Laravel jobs.dispatch(new Job)->onConnection('gearman')).gearman-worker).config/queue.php to default to Gearman for target jobs.gearman --statistics).gearman --max-threads).| Component | Compatibility Notes | Workarounds |
|---|---|---|
| Laravel Jobs | Must implement ShouldQueue and be serializable (JSON/PHP). |
Use enqueue/serializer for custom serialization. |
| Delayed Jobs | Not natively supported; requires Enqueue extensions or custom logic. | Use Queue::later() with a database fallback or cron-triggered retries. |
| Retry Logic | Limited; relies on Enqueue’s retry configuration. | Implement exponential backoff in job code or use a dead-letter queue. |
| Gearman Workers | Must handle job payloads (e.g., gearman --task-background). |
Write PHP worker scripts or use enqueue/consumer. |
| PHP Extensions | Requires pecl/gearman (may need compilation on some systems). |
Use Docker images with pre-installed Gearman (e.g., php:8.1-cli + Gearman). |
gearmand) on a dedicated host or container.gearman-worker --job-background --task-background).composer require enqueue/gearman enqueue/laravel enqueue/serializer
php artisan vendor:publish --tag=enqueue-config
config/queue.php:
'gearman' => [
'driver' => 'enqueue',
'transport' => 'gearman',
'host' => env('GEARMAN_HOST'),
'port' => env('GEARMAN_PORT', 4730),
'timeout' => 10.0,
],
gearman-worker.php):How can I help you explore Laravel packages today?