PHP code example of willypelz / queue-monitor

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

    

willypelz / queue-monitor example snippets


return [
    // Dashboard route path
    'path' => 'queue-monitor',

    // Middleware for dashboard access
    'middleware' => ['web'],

    // Storage driver: 'database' or 'redis'
    'driver' => env('QUEUE_MONITOR_DRIVER', 'database'),

    // Redis configuration (when driver is 'redis')
    'redis' => [
        'connection' => env('QUEUE_MONITOR_REDIS_CONNECTION', 'default'),
    ],

    // Retention period in days
    'retention_days' => 14,

    // UI refresh interval
    'ui' => [
        'refresh_seconds' => 10,
    ],

    // Control settings
    'control' => [
        'pause_release_seconds' => 10,
        'throttle_default_rate_per_minute' => 60,
        'throttle_release_seconds' => 5,
    ],
];

'middleware' => ['web', 'auth'],

'middleware' => ['web', 'auth', 'can:view-queue-monitor'],

use QueueMonitor\Services\QueueControlService;

$control = app(QueueControlService::class);

// Pause a queue
$control->pause('database', 'default');

// Resume a queue
$control->resume('database', 'default');

// Throttle a queue
$control->throttle('database', 'default', 30);

// Check if paused
$isPaused = $control->isPaused('database', 'default');

// Get throttle rate
$rate = $control->getThrottleRate('database', 'default');

protected function schedule(Schedule $schedule)
{
    $schedule->command('queue-monitor:prune')->daily();
}
bash
php artisan vendor:publish --provider="QueueMonitor\QueueMonitorServiceProvider"
bash
# Publish config
php artisan vendor:publish --tag=queue-monitor-config

# Publish migrations
php artisan vendor:publish --tag=queue-monitor-migrations

# Publish views (optional, for customization)
php artisan vendor:publish --tag=queue-monitor-views
bash
php artisan migrate
bash
# Prune records older than 14 days (default)
php artisan queue-monitor:prune

# Prune records older than 7 days
php artisan queue-monitor:prune --days=7