PHP code example of inna / think-rabbit-queue
1. Go to this page and download the library: Download inna/think-rabbit-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/ */
inna / think-rabbit-queue example snippets
use Inna\RabbitQueue\Job;
use Inna\RabbitQueue\ShouldQueue;
class CancelOrderJob extends Job implements ShouldQueue
{
public $order;
public function __construct($order)
{
$this->order = $order;
}
public function handle()
{
if ($this->order->shouldCancel()) {
$this->order->cancel();
}
}
}
use Carbon\Carbon;
use Inna\RabbitQueue\Queue;
$order = Order::find(1);
$job = (new CancelOrderJob($order))->delay(Carbon::now()->addDays(7));
$job->dispatch();
use Inna\RabbitQueue\Queue;
Queue::consume();