1. Go to this page and download the library: Download g4t/laravel-bee-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/ */
g4t / laravel-bee-queue example snippets
use G4T\BeeQueue\Facades\BeeQueue;
BeeQueue::createJob(['user_id' => 42, 'action' => 'send_welcome_email'])
->retries(3)
->backoff('exponential') // 'fixed' or 'exponential'
->retryDelay(5)
->delay(30) // run 30 seconds from now
->timeout(60)
->save();
// On a named queue
BeeQueue::queue('emails')
->createJob(['to' => '[email protected]'])
->save();
$worker = BeeQueue::worker();
$worker->process(function ($job) {
// $job->data contains your payload
$job->reportProgress(50);
// do work...
$job->reportProgress(100);
});
// app/Jobs/ProcessMessage.php
namespace App\Jobs;
use G4T\BeeQueue\Contracts\JobContract;
use G4T\BeeQueue\Job;
class ProcessMessage implements JobContract
{
public function __construct(private Job $job) {}
public function handle(): void
{
$data = $this->job->data;
// process $data...
}
}