PHP code example of neophp / queue-package

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/ */

    

neophp / queue-package example snippets


return [
    // ...
    'packages' => [
        \Vendor\NeoPHP\QueuePackage\NeoQueuePackage::class,
    ],
];



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);

    // ...
}

queue-package/
├── composer.json
├── README.md
├── src/
│   ├── NeoQueuePackage.php
│   ├── Command/
│   │   ├── QueueWorkCommand.php
│   │   ├── QueueRetryCommand.php
│   │   └── MakeJobCommand.php
│   ├── Service/
│   │   └── QueueManager.php
│   └── Interface/
│       └── JobInterface.php
└── database/
    ├── Entity/
    │   └── QueueJob.php
    ├── Repository/
    │   └── QueueJobRepository.php
    └── Migrations/
        └── MigrationVersion_Queue_1.php
cron
* * * * * php /path/to/bin/neo queue:work --project=MyProject >> /dev/null 2>&1
bash
php bin/neo database:migration:migrate --project=MyProject
bash
php bin/neo make:job SendWelcomeEmail --project=MyProject
bash
php bin/neo queue:work --project=MyProject
bash
php bin/neo queue:retry --project=MyProject