PHP code example of symphoria / laravel-apex

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

    

symphoria / laravel-apex example snippets


'queues' => [
    'chat' => [
        'profile' => 'latency-critical',
        'min_processes' => 0,           // nothing running when nothing is queued
        'min_processes_when_active' => 2, // warm pool while people are using the app
        'max_processes' => 8,
        'use_activity' => true,
    ],

    'reports' => [
        'profile' => 'background',
        'queues' => ['reports', 'reports-bulk'], // one pool reading several queues
        'max_processes' => 2,
    ],
],

'environments' => [
    'production' => ['queues' => ['chat' => ['max_processes' => 24]]],
],

// AppServiceProvider::boot()
Apex::auth(fn (Request $request) => $request->user()?->isAdmin() === true);

Gate::define('viewApex', fn ($user) => $user->can('admin.apex.dashboard.view'));

final class FeatureSuspensionSource implements QueueSuspensionSource
{
    public function suspendedQueues(): array
    {
        return Feature::disabled()
            ->flatMap(fn (string $name) => app(ApexConfig::class)->queuesForGroup($name))
            ->all();
    }
}

$this->app->bind(QueueSuspensionSource::class, FeatureSuspensionSource::class);

'queues' => [
    'invoices'  => ['profile' => 'throughput', 'group' => 'billing'],
    'reminders' => ['profile' => 'throughput', 'group' => 'billing'],
],

$this->app->bind(QueueSuspensionSource::class, LaravelPauseSuspensionSource::class);

'models' => [
    'queue_state' => App\Models\ApexQueueState::class,
],
bash
composer vendor:publish --tag=apex-config
php artisan migrate
php artisan apex:start