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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
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