dosomething/messagebroker-phplib
最新稳定版本:0.3.8
Composer 安装命令:
composer require dosomething/messagebroker-phplib
包简介
A library of functionality shared between the components that make up the DoSomething.org Message Broker system.
README 文档
README
A PHP baed library that ascts as a wrapper around the php-amqplib/php-amqplib AMQP PHP library.
The goal is to provide utility methods to simplify some of the more common activities of
interacting with a AMQP based (RabbitMQ) server.
Usage
Within the composer.json file of any PHP based application include this package with:
"require": {
"php": ">= 5.3.0",
"DoSomething/messagebroker-phplib": "0.3.*",
...
Create an instance of the class
// RabbitMQ
$rabbitCredentials = [
'host' => getenv("RABBITMQ_HOST"),
'port' => getenv("RABBITMQ_PORT"),
'username' => getenv("RABBITMQ_USERNAME"),
'password' => getenv("RABBITMQ_PASSWORD"),
'vhost' => getenv("RABBITMQ_VHOST"),
];
$config['exchange'] = array(
'name' => $exchangeSettings->name,
'type' => $exchangeSettings->type,
'passive' => $exchangeSettings->passive,
'durable' => $exchangeSettings->durable,
'auto_delete' => $exchangeSettings->auto_delete,
);
$config['queue'] = array(
'name' => $queueSetting->name,
'passive' => $queueSetting->passive,
'durable' => $queueSetting->durable,
'exclusive' => $queueSetting->exclusive,
'auto_delete' => $queueSetting->auto_delete,
'routingKey' => $queueSetting->routing_key,
'bindingKey' => $bindingKey,
);
$mb = new MessageBroker($rabbitCredentials, $config));
###Publish a message
$this->messageBroker->publish($message, <routing key>);
###Consume a message
How a message will be consumed is defined in the connection to the queue.
$config['consume'] = array(
'no_local' => $queueSetting->consume->no_local,
'no_ack' => $queueSetting->consume->no_ack,
'nowait' => $queueSetting->consume->nowait,
'exclusive' => $queueSetting->consume->exclusive,
);
The number of messages for the consumer to reserve with each callback. This is Necessary for parallel processing when more than one consumer is running on the same queue.
define('QOS_SIZE', 1);
$mb->consumeMessage([new consumer class(), <consumer method], QOS_SIZE);
where the consumed message details will be sent to consumer method>
public function <consumer method>($payload) {
####Gulp Support
Use a path directly to gulp ./node_modules/.bin/gulp or add an alias to your system config (.bash_profile) as alias gulp='./node_modules/.bin/gulp'
###Linting
gulp lint
See gulpfile.js for configuration and combinations of tasks.
##PHP CodeSniffer
-
php ./vendor/bin/phpcs --standard=./ruleset.xml --colors -s MessageBroker-Drupal.php src testsListing of all coding volations by file. -
php ./vendor/bin/phpcbf --standard=./ruleset.xml --colors MessageBroker-Drupal.php src testsAutomated processing of files to adjust to meeting coding standards.
###Test Coverage
gulp test
or
npm test
##PHP Unit
$ ./vendor/bin/phpunit --verbose tests
dosomething/messagebroker-phplib 适用场景与选型建议
dosomething/messagebroker-phplib 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.93k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2014 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rabbitmq」 「message broker php library」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dosomething/messagebroker-phplib 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dosomething/messagebroker-phplib 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dosomething/messagebroker-phplib 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Work with RabbitMQ in Laravel.
The library for publish/receive messages from broker (RabbitMQ).
Microservice RPC through message queues.
PHP AMQP Binding Library
Bdf queue component
Prime adapter for bdf queue component
统计信息
- 总下载量: 1.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-02-13