PHP code example of abinashbhatta / lightweight-queue-inspector

1. Go to this page and download the library: Download abinashbhatta/lightweight-queue-inspector 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/ */

    

abinashbhatta / lightweight-queue-inspector example snippets


return [

    // The URL prefix for the dashboard
    // Change this to move the dashboard to a different URL
    'path' => env('QUEUE_INSPECTOR_PATH', 'queue-inspector'),

    // Middleware applied to ALL dashboard routes
    // ⚠ Always keep 'auth' here in production!
    'middleware' => ['web', 'auth'],

    // Your jobs table name — only change if you renamed it
    'jobs_table' => env('QUEUE_JOBS_TABLE', 'jobs'),

    // Your failed jobs table name — only change if you renamed it
    'failed_jobs_table' => env('QUEUE_FAILED_JOBS_TABLE', 'failed_jobs'),

    // The metrics table created by this package — do not rename
    'metrics_table' => 'queue_job_metrics',

    // How many jobs to show per page
    'per_page' => 20,

];

// Basic — any logged in user can access
'middleware' => ['web', 'auth'],

// Specific guard
'middleware' => ['web', 'auth:sanctum'],

// Admin only (recommended for production teams)
'middleware' => ['web', 'auth', App\Http\Middleware\EnsureUserIsAdmin::class],

use AbinashBhatta\QueueInspector\Facades\QueueInspector;

// Get dashboard stats
$stats = QueueInspector::getStats();
// Returns: total_pending, total_failed, total_success,
//          avg_execution_time, top_failing_job, available_queues

// Get pending jobs (optional filters)
$jobs = QueueInspector::getPendingJobs();
$jobs = QueueInspector::getPendingJobs(queue: 'emails');
$jobs = QueueInspector::getPendingJobs(jobClass: 'SendEmailJob');

// Get failed jobs
$jobs = QueueInspector::getFailedJobs();
$jobs = QueueInspector::getFailedJobs(queue: 'payments');

// Get successful jobs
$jobs = QueueInspector::getSuccessJobs();

// Actions
QueueInspector::retryJob($id);           // Retry one failed job
QueueInspector::deleteFailedJob($id);    // Delete one failed job
$count = QueueInspector::retryAllJobs();        // Retry all failed jobs
$count = QueueInspector::clearAllFailedJobs();  // Delete all failed jobs
bash
php artisan queue:table
php artisan migrate
bash
php artisan queue:failed-table
php artisan migrate
bash
php artisan migrate
bash
php artisan vendor:publish --tag=queue-inspector-config
bash
php artisan vendor:publish --tag=queue-inspector-views