PHP code example of jamesjulius / laravel-nexus

1. Go to this page and download the library: Download jamesjulius/laravel-nexus 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/ */

    

jamesjulius / laravel-nexus example snippets




return [
    'workers' => [
        'default' => [
            'queue' => 'default',
            'connection' => env('QUEUE_CONNECTION', 'database'),
            'tries' => 3,
            'timeout' => 60,
            'sleep' => 3,
            'memory' => 128,
            'processes' => 2,
            'max_jobs' => 1000,
            'max_time' => 3600,
        ],
        'broadcasting' => [
            'queue' => 'broadcasting',
            'connection' => env('QUEUE_CONNECTION', 'database'),
            'tries' => 3,
            'timeout' => 30,
            'sleep' => 1,
            'memory' => 128,
            'processes' => 1,
            'max_jobs' => 500,
            'max_time' => 3600,
        ],
        // ... more workers
    ],

    'environment' => env('APP_ENV', 'production'),
    'prefix' => env('NEXUS_PREFIX', 'nexus'),
    'auto_restart' => true,
    'restart_signal_file' => storage_path('framework/cache/laravel-queue-restart'),
];

// Jobs
class ProcessPayment implements ShouldQueue
{
    public $queue = 'payments'; // ✅ Detected
}

// Events
class OrderShipped implements ShouldBroadcast
{
    public function broadcastQueue()
    {
        return 'broadcasting'; // ✅ Detected
    }
}

// Mail
class WelcomeEmail extends Mailable implements ShouldQueue
{
    use Queueable;

    public function __construct()
    {
        $this->onQueue('mail'); // ✅ Detected
    }
}

// Notifications
class InvoiceGenerated extends Notification implements ShouldQueue
{
    public $queue = 'notifications'; // ✅ Detected
}
bash
# The daily struggle with complex Laravel apps...
php artisan queue:work --queue=default &
php artisan queue:work --queue=broadcasting --timeout=30 &
php artisan queue:work --queue=mail --timeout=120 &
php artisan queue:work --queue=notifications --sleep=1 &
php artisan queue:work --queue=edi-processing --timeout=300 --memory=256 &
php artisan queue:work --queue=payments --tries=5 &

# ...and trying to manage/monitor them all locally! 😵‍💫
bash
# Simple way
php artisan nexus:publish

# Or using vendor:publish directly
php artisan vendor:publish --provider="JamesJulius\LaravelNexus\NexusServiceProvider" --tag="nexus-config"
bash
php artisan nexus:configure
bash
# Comprehensive help guide
php artisan nexus:help

# Command-specific help
php artisan help nexus:configure
php artisan help nexus:work
bash
php artisan nexus:configure
# Select your queues
# Choose "Yes" for "Would you like to configure advanced global defaults?"
bash
php artisan nexus:configure
# Enable advanced global defaults
# Choose "Yes" for "Use simplified configuration mode?"
bash
php artisan nexus:work --watch
bash
# 1. Configure queues
php artisan nexus:configure

# 2. Start workers (use process manager like Supervisor)
php artisan nexus:work
bash
# Re-scan for queues
php artisan nexus:configure --discover

# Check specific queue
php artisan nexus:configure --list-jobs --queue=default
bash
# Check configuration
cat config/nexus.php

# Check worker status
php artisan nexus:work --status

# Force restart
php artisan nexus:work --restart