用于访问 RabbitMQ (AMQP) 的最佳 PHP 客户端库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4405992/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Best PHP client library for accessing RabbitMQ (AMQP)?
提问by dkamins
There is a list of PHP clients on the RabbitMQ site. I'm asking this question in hopes that people who have used any of these can share their experiences here. E.g.
RabbitMQ 站点上有一个PHP 客户端列表。我问这个问题是希望使用过其中任何一种的人可以在这里分享他们的经验。例如
- Did you have any trouble installing?
- Is it stable?
- Were there any performance issues?
- How is the documentation / support?
- 你安装有没有遇到什么问题?
- 它稳定吗?
- 是否有任何性能问题?
- 文档/支持如何?
Even if you've just used one of these libraries, please share your experiences.
即使您只使用过这些库之一,也请分享您的经验。
For reference, here are some of the clients listed:
作为参考,这里列出了一些客户:
- PHP manual page for AMQP
- php-amqp - a client developed and used by StudiVZ, originally based on RabbitMQ-C
- php-amqplib a port of py-amqplib
- php-amqplib a fork of php-amqplib updated to support PHP 5.3
- PECL release of the AMQP client
- AMQP 的 PHP 手册页
- php-amqp - StudiVZ 开发和使用的客户端,最初基于 RabbitMQ-C
- php-amqplib py-amqplib 的一个端口
- php-amqplib 更新了 php-amqplib 的一个分支以支持 PHP 5.3
- AMQP 客户端的 PECL 版本
P.S. I know that "Best ..." is "subjective", but the point of this question is to collect experiences and help people make an informed decision about these AMQP libraries. Please don't knee-jerk close this question just because it has the word "best" in it.
PS 我知道“最好的……”是“主观的”,但这个问题的重点是收集经验并帮助人们对这些 AMQP 库做出明智的决定。请不要下意识地关闭这个问题,因为它有“最好”这个词。
P.P.S. I'm using PHP 5.3 on RHEL 5.
PPS 我在 RHEL 5 上使用 PHP 5.3。
采纳答案by Pieter
For reference, PECL AMQP Extensionand http://php.net/manual/fa/book.amqp.phpare the same thing, one is the package, the other the documentation for the package.
作为参考,PECL AMQP Extension和http://php.net/manual/fa/book.amqp.php是一回事,一个是包,另一个是包的文档。
As a maintainer of the official PHP AMQP extension, I am a little biased. Many people use this extension in high volume low latency production environments since it is far faster than one written in native PHP. Furthermore, since I constantly use this at my job, I have to keep it working and up to date.
作为官方 PHP AMQP 扩展的维护者,我有点偏颇。许多人在大容量低延迟生产环境中使用此扩展,因为它比用原生 PHP 编写的要快得多。此外,由于我在工作中经常使用它,因此我必须保持它的工作状态并保持最新状态。
The drawback to this extension is that it is not available for Windows, yet, because the library on which it depends is currently being ported. There is not ETA for Windows support, but as soon as the dependencies support Windows, it is our goal to port the extension over to Windows as well.
此扩展的缺点是它尚不可用于 Windows,因为它所依赖的库当前正在移植。Windows 支持没有 ETA,但是一旦依赖项支持 Windows,我们的目标就是将扩展移植到 Windows。
回答by Tomas Dermisek
This library seem to be alive and succeeding the original from code.google:
这个库似乎还活着并继承了 code.google 的原始库:
https://github.com/videlalvaro/php-amqplib
https://github.com/videlalvaro/php-amqplib
There are also tests and Travis CI.
还有测试和 Travis CI。
回答by dkamins
Some info from initial review:
初步的一些信息:
https://github.com/tnc/php-amqplibforked http://code.google.com/p/php-amqplib/at an unknown point in the past and does not have a clear history or show what was changed, which results in an unfortunate fragmentation of efforts. It also appears to NOT be keeping up with bugfixes being applied to the original, a number of which have come in the last few months.
https://github.com/tnc/php-amqplib在过去的一个未知点 分叉 http://code.google.com/p/php-amqplib/并且没有明确的历史记录或显示发生了什么变化,不幸的是,这导致了努力的分散。它似乎也没有跟上应用于原始版本的错误修正,其中一些是在过去几个月中出现的。
Also http://code.google.com/p/php-amqplib/itself now appears to be no longer under active development, and a bad patch was applied over a month ago leaving the trunk in a broken state. (I submitted a patch to fix that, but this is a bad sign).
此外,http://code.google.com/p/php-amqplib/本身现在似乎不再处于积极开发状态,并且一个多月前应用了一个糟糕的补丁,使主干处于损坏状态。(我提交了一个补丁来解决这个问题,但这是一个不好的迹象)。
回答by aib
There's also https://github.com/bkw/php-amqp/which I think is a mirror of http://code.google.com/p/php-amqplib/. I've had some trouble with that code: Notice messages during normal operation and all kinds of errors and warnings when there's something wrong. The code also takes the PHP manual's word for granted; for example, socket read calls are only checked against an error return, while in fact I'm just discovering that a socket close/timeout may be indicated by any of 4 different conditions.
还有https://github.com/bkw/php-amqp/我认为它是http://code.google.com/p/php-amqplib/的镜像。我在使用该代码时遇到了一些问题:在正常操作期间注意消息以及出现问题时的各种错误和警告。该代码也将 PHP 手册中的词视为理所当然;例如,仅针对错误返回检查套接字读取调用,而实际上我只是发现套接字关闭/超时可能由 4 种不同条件中的任何一种指示。
I'm starting to think that a compiled library solution (i.e. a PHP extension) is the best option, particularly since there're threading and socket issues, and PHP handles both poorly.
我开始认为编译库解决方案(即 PHP 扩展)是最好的选择,特别是因为存在线程和套接字问题,而 PHP 对两者的处理都很差。
回答by dimdm
Having looked at both php-amqp and the PECL version, my impressions are that basic support for publishing and consuming messages is implemented. However, they will only work out of the box on *NIX platforms. You will have to jump through hoops to make them work on Windows (which may or may not be a problem depending on your development or deployment platform).
查看了 php-amqp 和 PECL 版本后,我的印象是实现了对发布和使用消息的基本支持。但是,它们只能在 *NIX 平台上开箱即用。您将不得不跳过障碍才能使它们在 Windows 上工作(这可能是也可能不是问题,具体取决于您的开发或部署平台)。
Bonus: https://github.com/tnc/php-amqplibis used in the MEAP book "RabbitMQ in Action". Whether that will have any influence on its adoption remains to be seen.
奖励:https: //github.com/tnc/php-amqplib用于 MEAP 书籍“RabbitMQ in Action”。这是否会对它的采用产生任何影响还有待观察。
回答by Maksim Kotlyar
We are working on amqp interop. It tries to identify and standardize a common way for PHP programs to create, send, receive and read MQ messages through AMQP to achieve interoperability.
我们正在研究amqp interop。它试图识别和规范 PHP 程序通过 AMQP 创建、发送、接收和读取 MQ 消息的通用方式,以实现互操作性。
If you place a bet on it you can start with any interop compatible transport. You'll still be able to change it in future, you are not locked in.
如果您对此下注,您可以从任何兼容互操作的传输开始。您将来仍然可以更改它,您不会被锁定。
We currently supports enqueue/amqp-extand enqueue/amqp-lib. First one works on top of php amqp extension where another adopts phpamqplib.
我们目前支持enqueue/amqp-ext和enqueue/amqp-lib。第一个工作在 php amqp 扩展之上,另一个采用 phpamqplib。