1. Go to this page and download the library: Download neophp/queue-package 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/ */
declare(strict_types=1);
namespace Neo\Src\MyProject\App\Job;
use Vendor\NeoPHP\QueuePackage\Interface\JobInterface;
final class SendWelcomeEmailJob implements JobInterface
{
public function __construct(private readonly int $userId)
{
}
public function handle(): void
{
// your logic here — e.g. resolve the user and send an email
}
}
public function register(Request $request, QueueManager $queue): Response
{
// ...
$queue->push(new SendWelcomeEmailJob($user->getId()));
// with an explicit queue name and priority (higher runs first)
$queue->push(new SendWelcomeEmailJob($user->getId()), queue: 'emails', priority: 10);
// ...
}