PHP code example of jmhc / laravel-rabbitmq

1. Go to this page and download the library: Download jmhc/laravel-rabbitmq 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/ */

    

jmhc / laravel-rabbitmq example snippets


// 任务类
use Jmhc\Rabbitmq\Jobs\BaseRabbitmq;

class CustomJob extends BaseRabbitmq
{
    // 自行实现逻辑
    public function handle()
    {
        // 调用任务时传递的数据为 msg
        // $this->msg->key === 'value';
    }
}

// 调用任务类
CustomJob::dispatch([
    'key' => 'value',
    ...
]);
shell script
php artisan queue:work rabbitmq