项目作者: mucts

项目描述 :
根据PHP-AMQPLIB插件二次开发,基于Laravel 7.0框架的RabbitMQ插件。
高级语言: PHP
项目地址: git://github.com/mucts/laravel-amqp.git
创建时间: 2020-07-12T05:55:09Z
项目社区:https://github.com/mucts/laravel-amqp

开源协议:

下载




Build Status
Code Intelligence Status
Scrutinizer Code Quality
Total Downloads
Latest Stable Version
License

Laravel AMQP

AMQPMessage SDK for Laravel 8

Installation

Server Requirements

you will need to make sure your server meets the following requirements:

  • php ^8.0
  • JSON PHP Extension
  • Sockets PHP Extension
  • MBString PHP Extension
  • php-amqplib/php-amqplib 3.0
  • laravel/framework ^8.41

Laravel Installation

  1. composer require mucts/laravel-amqp

Usage

  • AMQPMessage publisher
    ```php
    <?php
    use MuCTS\Laravel\AMQP\Facades\AMQP;
    use PhpAmqpLib\Exchange\AMQPExchangeType;

// send message
AMQP::connection(‘default’)
->setExchange(‘test’)
->setExchangeType(AMQPExchangeType::TOPIC)
->setQueue(‘test’)
->publish(‘test’);

  1. - AMQPMessage consumer
  2. ```php
  3. use MuCTS\Laravel\AMQP\Commands\AMQPCommand;
  4. use PhpAmqpLib\Message\AMQPMessage;
  5. use Illuminate\Support\Facades\Log;
  6. use PhpAmqpLib\Exchange\AMQPExchangeType;
  7. class test extends AMQPCommand{
  8. protected string $exchange = 'test';
  9. protected string $queue = 'test';
  10. protected string $exchangeType = AMQPExchangeType::TOPIC;
  11. protected string $consumerTag = 'consumer';
  12. protected ?string $connectionName = 'default';
  13. protected bool $autoAsk = false;
  14. protected function processMessage(AMQPMessage $message){
  15. Log::info($message->getBody());
  16. // message ask
  17. $message->ack();
  18. // message nack
  19. $message->nack(true);
  20. }
  21. }

Configuration

If config/amqp.php not exist, run below:

  1. php artisan vendor:publish