PHP code example of jeffersongoncalves / laravel-queue-management

1. Go to this page and download the library: Download jeffersongoncalves/laravel-queue-management library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jeffersongoncalves / laravel-queue-management example snippets


return [
    'tables' => [
        'jobs' => 'jobs',
        'failed_jobs' => 'failed_jobs',
        'job_batches' => 'job_batches',
    ],
];

use JeffersonGoncalves\QueueManagement\Models\Job;
use JeffersonGoncalves\QueueManagement\Models\FailedJob;
use JeffersonGoncalves\QueueManagement\Models\JobBatch;

// Pending jobs
$pending = Job::query()->get();
$first = $pending->first();
$first->displayName; // e.g. "App\Jobs\SendEmail"
$first->maxTries;    // int
$first->delay;       // int

// Failed jobs
$failed = FailedJob::query()->get();
$failed->first()->failed_at; // Carbon instance

// Job batches (options are transparently base64 decoded)
$batches = JobBatch::query()->get();
$batches->first()->options;

use JeffersonGoncalves\QueueManagement\QueueManager;

$manager = app(QueueManager::class);

// Retry one or more failed jobs (by failed_jobs.id).
// When queue.failed.driver is "database-uuids" the uuid is used automatically.
$manager->retry(1, 2, 3);

// Retry every failed job
$manager->retryAll();

// Forget a single failed job by id or uuid
$manager->forget(1);

// Flush all failed jobs
$manager->flush();

// Delete a pending job from the jobs table by id
$manager->deletePendingJob(10);

use JeffersonGoncalves\QueueManagement\Facades\QueueManagement;

QueueManagement::retry(1, 2, 3);
QueueManagement::retryAll();
QueueManagement::forget(1);
QueueManagement::flush();
QueueManagement::deletePendingJob(10);
bash
php artisan vendor:publish --tag=queue-management-config