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

Resque Laravel Package

allprogrammic/resque

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require allprogrammic/resque
    

    Ensure php-redis is installed (pecl install redis).

  2. Configuration Publish the config file:

    php artisan vendor:publish --provider="Allprogrammic\Resque\ResqueServiceProvider"
    

    Update .env with Redis connection details:

    RESQUE_CONNECTION=redis
    RESQUE_QUEUE=default
    
  3. First Job Create a job class:

    namespace App\Jobs;
    
    use Allprogrammic\Resque\Job as ResqueJob;
    
    class ProcessData extends ResqueJob
    {
        public function perform()
        {
            // Your job logic here
            \Log::info('Processing data...');
        }
    }
    
  4. Enqueue a Job

    use App\Jobs\ProcessData;
    
    ProcessData::dispatch();
    
  5. Run the Worker

    php artisan resque:work
    

Implementation Patterns

Workflow Integration

  • Dispatching Jobs Use dispatch() or dispatchOn() for queue-specific jobs:

    ProcessData::dispatchOn('high_priority')->delay(now()->addMinutes(5));
    
  • Job Chaining Chain jobs sequentially:

    ProcessData::dispatch()
        ->then(new \App\Jobs\CleanupData());
    
  • Bulk Processing Enqueue multiple jobs in a loop:

    foreach ($items as $item) {
        ProcessItem::dispatch($item)->onQueue('batch');
    }
    

Worker Management

  • Multiple Workers Run workers in separate terminals for parallel processing:

    php artisan resque:work --queue=default &
    php artisan resque:work --queue=high_priority &
    
  • Supervisor Setup Use supervisord to manage workers as services (recommended for production).

Error Handling

  • Failed Jobs Implement onFailure() in jobs:

    public function onFailure($exception)
    {
        \Log::error("Job failed: " . $exception->getMessage());
    }
    
  • Retry Logic Configure retries in config/resque.php:

    'retry' => [
        'max_attempts' => 3,
        'delay' => 60, // seconds
    ],
    

Gotchas and Tips

Common Pitfalls

  • Redis Connection Issues Ensure Redis is running and accessible. Test with:

    redis-cli ping
    

    Verify .env has correct Redis host/port.

  • Job Stuck in Queue Check for infinite loops or deadlocks. Use resque:remove to debug:

    php artisan resque:remove ProcessData --queue=default
    
  • Worker Crashes Logs may not persist if Redis connection drops. Use monolog for job-level logging.

Debugging Tips

  • Inspect Queues List queued jobs:

    php artisan resque:list
    

    Peek at a job:

    php artisan resque:peek ProcessData --queue=default
    
  • Xdebug with Workers Attach Xdebug to the worker process for step-through debugging.

Extension Points

  • Custom Job Serialization Override serialize()/unserialize() for complex payloads:

    protected function serialize()
    {
        return json_encode(['data' => $this->data]);
    }
    
  • Middleware for Jobs Use Resque::middleware() to add pre/post hooks:

    Resque::middleware(function ($job, $next) {
        \Log::info("Job {$job->class} started");
        return $next($job);
    });
    
  • Custom Worker Classes Extend Allprogrammic\Resque\Worker for specialized behavior (e.g., custom failure handling).

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.
testo/facade
headercat/phpstan-extension-ide-helper
yosymfony/parser-utils
innmind/black-box
babenkoivan/elastic-migrations
babenkoivan/elastic-adapter
sandermuller/package-boost-php
sandermuller/boost-core
depa/sulu-google-reviews-bundle
croct/plug-symfony
develia/commons
dmstr/symfony-system-resources-bundle
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
renatomarinho/laravel-page-speed
develia/geo-bundle
austinheap/laravel-database-encryption
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle