PHP code example of fahriar / laravel-shared-queue
1. Go to this page and download the library: Download fahriar/laravel-shared-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/ */
namespace App\Tasks;
use LaravelSharedQueue\Contracts\TaskHandler;
use Illuminate\Support\Facades\Log;
class SendInvoiceEmailTask implements TaskHandler
{
public function handle(array $payload): void
{
// Business logic here.
Log::info("Sending email for invoice: " . $payload['invoice_id']);
}
}
use LaravelSharedQueue\Facades\SharedQueue;
SharedQueue::dispatch('send_invoice_email', [
'invoice_id' => 1001,
]);
// Or securely dispatch using the global helper:
shared_queue('send_invoice_email', ['invoice_id' => 1001]);