Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Pheanstalk Laravel Package

enqueue/pheanstalk

Enqueue Beanstalk Transport integrates Beanstalkd with the Enqueue queue specification, letting you send and consume messages via the Pheanstalk client. Includes docs, CI, and Packagist distribution for PHP apps and workers.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Queue Abstraction Alignment: The enqueue/pheanstalk package leverages the Queue Interop standard, making it a seamless fit for Laravel applications requiring asynchronous job processing or event-driven architectures. It extends Laravel’s queue ecosystem beyond Redis/SQS/database to include Beanstalkd, a lightweight, high-performance message broker ideal for:
    • Low-latency, high-throughput workloads (e.g., real-time notifications, API calls).
    • Priority-based job execution (Beanstalkd’s native tube prioritization).
    • Legacy system integration where Beanstalkd is already deployed.
  • Laravel Ecosystem Synergy: While Laravel’s native queue system (Illuminate\Queue) supports Redis, database, and SQS, this package enables Beanstalkd integration without reinventing the wheel. The Enqueue library’s abstraction layer ensures compatibility with Laravel’s ShouldQueue jobs, provided a serialization bridge is implemented.
  • Future-Proofing: Adhering to Queue Interop, the package allows for transport-agnostic development. If requirements evolve (e.g., need for persistence or clustering), the system can migrate to other Enqueue transports (e.g., RabbitMQ, Redis) with minimal code changes.

Integration Feasibility

  • Laravel Queue Connector:
    • Requires a custom queue connector or the enqueue/laravel package (if available) to bridge Laravel’s Queue facade to Enqueue’s Beanstalkd transport.
    • Example: Extend Illuminate\Queue\QueueManager to register enqueue/pheanstalk as a driver.
  • Job Serialization:
    • Laravel jobs (e.g., closures, objects) must be serialized/deserialized for Beanstalkd. The enqueue/serializer package or a custom adapter (e.g., JSON, PHP serialize()) is needed.
    • Risk: Complex job payloads (e.g., resources, non-serializable objects) may fail without proper handling.
  • Connection Management:
    • Beanstalkd requires Pheanstalk client configuration (pda/pheanstalk), including host, port, and timeouts. Laravel’s queue.php config must be extended to support this.
    • Example:
      'connections' => [
          'beanstalkd' => [
              'driver' => 'enqueue',
              'transport' => 'pheanstalk',
              'dsn' => 'pheanstalk://user:pass@beanstalkd:11300',
          ],
      ],
      
  • Worker Adaptation:
    • Laravel’s queue:work command may need replacement with Enqueue’s enqueue:consume for full feature parity (e.g., retry logic, dead-letter queues).

Technical Risk

Risk Area Impact Mitigation Strategy
Laravel Integration Gaps High Develop a custom queue connector or adopt enqueue/laravel if available.
Serialization Failures Medium Use enqueue/serializer or implement a fallback serializer for Laravel jobs.
Beanstalkd Dependency High (Operational) Ensure high availability (managed service or clustering) and monitoring.
Performance Overhead Medium Benchmark against Laravel’s native drivers (Redis, database) for latency/throughput.
Error Handling Medium Extend Laravel’s queue listeners to handle Beanstalkd-specific errors (e.g., timeouts).
Job Retry Logic Medium Leverage Enqueue’s retry middleware or implement custom retry logic in workers.

Key Questions

  1. Architectural Justification:
    • Why choose Beanstalkd over Laravel’s native drivers (Redis/SQS) or other Enqueue transports (RabbitMQ)?
    • Does the team have experience with Beanstalkd or a willingness to adopt it?
  2. Laravel Compatibility:
    • Is the enqueue/laravel package available, or must a custom bridge be built?
    • How will Laravel’s ShouldQueue jobs (e.g., closures, resources) be serialized/deserialized?
  3. Operational Feasibility:
    • Who will manage the Beanstalkd server (scaling, failover, backups)?
    • Are there existing monitoring tools (e.g., Prometheus, custom scripts) for queue health?
  4. Migration Strategy:
    • If migrating from another queue (e.g., Redis), what’s the data migration plan?
    • How will existing Laravel queue workers (e.g., php artisan queue:work) be adapted?
  5. Failure Modes:
    • What’s the recovery strategy for Beanstalkd crashes (in-memory data loss)?
    • How will dead-letter queues or failed job tracking be implemented?

Integration Approach

Stack Fit

  • Core Components:
    • Laravel: Application layer using Illuminate\Queue facade, extended to support Enqueue’s Beanstalkd transport.
    • Enqueue: Abstraction layer providing Queue Interop compliance and Beanstalkd-specific logic.
    • Beanstalkd: Backend queue broker (lightweight, in-memory, prioritized tubes).
  • Alternatives Evaluated:
    • Laravel Native Drivers: Redis/SQS offer tighter Laravel integration but lack Beanstalkd’s prioritization.
    • Other Enqueue Transports: RabbitMQ or Amazon SQS provide persistence/clustering but add complexity.
  • Justification for Beanstalkd:
    • Performance: Ideal for low-latency, high-throughput scenarios (e.g., real-time processing).
    • Simplicity: Minimal setup (single binary) and no external dependencies.
    • Prioritization: Native support for job prioritization via tubes.

Migration Path

  1. Phase 1: Infrastructure Setup
    • Deploy Beanstalkd (self-hosted or managed service like IronMQ).
    • Configure monitoring (e.g., beanstalkd-stats, Prometheus exporters).
    • Set up backups (e.g., database logs for critical jobs) to mitigate in-memory data loss.
  2. Phase 2: Dependency Integration
    • Install required packages:
      composer require enqueue/pheanstalk pda/pheanstalk enqueue/serializer
      
    • Configure Laravel’s queue.php to use the Beanstalkd transport:
      'connections' => [
          'beanstalkd' => [
              'driver' => 'enqueue',
              'transport' => 'pheanstalk',
              'dsn' => env('BEANSTALKD_DSN', 'pheanstalk://localhost:11300'),
              'options' => [
                  'timeout' => 5.0,
                  'read_write_timeout' => 2.0,
              ],
          ],
      ],
      
  3. Phase 3: Laravel Queue Bridge
    • Option A: Use enqueue/laravel (if available) for seamless integration.
    • Option B: Build a custom queue connector:
      // app/Providers/QueueServiceProvider.php
      public function register()
      {
          Queue::extend('enqueue', function ($app) {
              return new EnqueueQueueService(
                  new PheanstalkContext(env('BEANSTALKD_DSN'))
              );
          });
      }
      
  4. Phase 4: Job Serialization
    • Implement a serializer adapter for Laravel jobs:
      // app/Providers/AppServiceProvider.php
      public function boot()
      {
          $serializer = new JsonSerializer();
          Enqueue::setSerializer($serializer);
      }
      
    • Test with a sample job:
      class SendEmailJob implements ShouldQueue
      {
          public function handle() { /* ... */ }
      }
      
  5. Phase 5: Worker Adaptation
    • Replace queue:work with Enqueue’s consumer:
      php artisan enqueue:consume beanstalkd --memory=512M
      
    • Configure Supervisor/Cron to use the new command.

Compatibility

Component Compatibility Notes
Laravel Version Tested with Laravel 9/10; requires PHP 8.1+.
Enqueue Version Must align with enqueue/pheanstalk’s dependencies (e.g., queue-interop/queue-interop).
Beanstalkd Version Compatible with Pheanstalk 3.1+; server version should match client requirements.
Laravel Jobs Custom serialization may be needed for complex payloads (e.g., closures, resources).
Existing Workers `queue:
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor