PHP code example of guandeng / laravel-rabbitmq

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

    

guandeng / laravel-rabbitmq example snippets


php artisan publisher:rabbitmq DirectPublisher test

public function publish()
{
    // 向所有生产者发送消息
    $publishers = config('rabbitmq.publishers');
    foreach ($publishers as $publisher => $exchange) {
        $messages = [
            'key' => 'hello world' 
        ];
        app('rabbitmq')->exchange($exchange)->publish($messages);
    }
}

 php artisan consumer:rabbitmq DirectConsumer