PHP code example of solophp / job-queue

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

    

solophp / job-queue example snippets


use Solo\JobQueue\JobQueue;
use Solo\JobQueue\Codec\ContainerJobCodec;
use Solo\JobQueue\Storage\{DbalJobStorage, Schema};
use Solo\JobQueue\Worker\{Worker, WorkerLimits};

Schema::install($connection);

$queue = new JobQueue(
    storage: new DbalJobStorage($connection),
    codec: new ContainerJobCodec($container), // a PSR-11 container
);

// SendEmailJob implements Solo\JobQueue\Codec\PersistableJobInterface.
$queue->push(new SendEmailJob('[email protected]', 'Welcome'), 'email');

// In a long-running process under a supervisor:
$worker = new Worker(
    queue: $queue,
    type: 'email',
    limits: new WorkerLimits(maxJobs: 1000, maxRuntime: 3600),
);
$worker->run();