承接 alive2212/laravel-amqp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alive2212/laravel-amqp

Composer 安装命令:

composer require alive2212/laravel-amqp

包简介

{This is Fork of anik/amqp package} of php-amqplib wrapper that eases the consumption of RabbitMQ. A painless way of using RabbitMQ

README 文档

README

This is fork of anik/amqp for our usage. in this package we change 'resolveConnectionName' and 'getConnection' method to a public method, to customize our channel and queue and exchange. Many Many Thanks anik/amqp anik/amqp

anik/amqp is a php-amqplib wrapper that eases the consumption of RabbitMQ. A painless way of using RabbitMQ.

You can use this package with

Requirements

This package requires the following

  • php >= 7.0
  • ext-bcmath
  • ext-sockets

Installation

The package works with Laravel, Lumen & Laravel zero. Install it via composer.

composer require anik/amqp

For Laravel 

The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php providers array:

'providers' => [
    /// ... 
    Anik\Amqp\ServiceProviders\AmqpServiceProvider::class,
]
  • Add configuration file amqp.php in your config directory with the following command.
php artisan vendor:publish --provider="Anik\Amqp\ServiceProviders\AmqpServiceProvider"

For Lumen

  • Add the service provider in your bootstrap/app.php file.
$app->register(Anik\Amqp\ServiceProviders\AmqpServiceProvider::class);
  • Add configuration amqp.php in your config directory by copying it from vendor/anik/amqp/src/config/amqp.php. Don't forget to add $app->configure('amqp'); to your bootstrap/app.php.

N.B: For Lumen, you don't need to enable Facade.

For Laravel Zero

  • Add provider in your config/app.php providers array.
'providers' => [
    /// ... 
    Anik\Amqp\ServiceProviders\AmqpServiceProvider::class,
]
  • Add configuration amqp.php in your config directory by copying it from vendor/anik/amqp/src/config/amqp.php.

Usage

  • To Publish a message
<?php
// AmqpManager::publish($msg, $routing, $config);
app('amqp')->publish('Message to direct exchange', 'routing-key', [
    'exchange' => [
        'type'    => 'direct',
        'name'    => 'direct.exchange',
    ],
]);
  • To consume a message
<?php
use Anik\Amqp\ConsumableMessage;

// AmqpManager::consume($consumerHandler, $bindingKey, $config);
app('amqp')->consume(function (ConsumableMessage $message) {
    echo $message->getStream() . PHP_EOL;
    $message->getDeliveryInfo()->acknowledge();
}, 'routing-key', [
    'connection' => 'my-connection-name',
    'exchange'   => [
        'type'    => 'direct',
        'name'    => 'direct.exchange',
    ],
    'queue' => [
        'name'         => 'direct.exchange.queue',
        'declare'      => true,
        'exclusive'    => false,
    ],
    'qos' => [
        'enabled'            => true,
        'qos_prefetch_count' => 5,
    ],
]);

Documentation

The full documentation of this package is written in this article

Issues & PR

To err is human.

  • If the package generates any issue, please report it. Mention procedures to reproduce it.
  • I would like to merge your PRs if they enrich the package or solve any existing issue.

统计信息

  • 总下载量: 62
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固