Recommend this page to a friend! |
Classes of Hillary Kollan | Chatto PHP Websocket Chat System | vendor/php-amqplib/php-amqplib/README.md | Download |
|
Downloadphp-amqplib[![Latest Version on Packagist][ico-version]][link-packagist] [![Software License][ico-license]](LICENSE) [![Build Status][ico-travis]][link-travis] [![Coverage Status][ico-scrutinizer]][link-scrutinizer] [![Quality Score][ico-code-quality]][link-code-quality] [![Total Downloads][ico-downloads]][link-downloads] This library is a _pure PHP_ implementation of the AMQP 0-9-1 protocol. It's been tested against RabbitMQ. Requirements: PHP 5.3 due to the use of Requirements: bcmath and mbstring extensions This library utilizes the bcmath and mbstring PHP extensions. The installation steps vary per PHP version and the underlying OS. The following example shows how to add to an existing PHP installation on Ubuntu 15.10:
The library was used for the PHP examples of RabbitMQ in Action and the official RabbitMQ tutorials. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. Project MaintainersThanks to videlalvaro and postalservice14 for their hard work maintaining php-amqplib! The library wouldn't be where it is without them. The package is now maintained by nubeiro and several Pivotal engineers working on RabbitMQ and related projects. Supported RabbitMQ VersionsStarting with version 2.0 this library uses Supported RabbitMQ ExtensionsSince the library uses
Extensions that modify existing methods like Related libraries
SetupEnsure you have composer installed, then run the following command:
That will fetch the library and its dependencies inside your vendor folder. Then you can add the following to your .php files in order to use the library
Then you need to
UsageWith RabbitMQ running open two Terminals and on the first one execute the following commands to start the consumer:
Then on the other Terminal do:
You should see the message arriving to the process on the other Terminal Then to stop the consumer, send to it the
If you need to listen to the sockets used to connect to RabbitMQ then see the example in the non blocking consumer.
Change logPlease see CHANGELOG for more information what has changed recently. TutorialsTo not repeat ourselves, if you want to learn more about this library, please refer to the official RabbitMQ tutorials. More Examples
Batch PublishingLet's say you have a process that generates a bunch of messages that are going to be published to the same
and then send the batch like this:
When do we publish the message batch?Let's say our program needs to read from a file and then publish one message per line. Depending on the message size, you will have to decide when it's better to send the batch. You could send it every 50 messages, or every hundred. That's up to you. Optimized Message PublishingAnother way to speed up your message publishing is by reusing the
Now let's say that while you want to change the message body for future messages, you will keep the same properties, that is, your messages will still be
Truncating Large MessagesAMQP imposes no limit on the size of messages; if a very large message is received by a consumer, PHP's memory limit may be reached
within the library before the callback passed to To avoid this, you can call the method Note that all data above the limit is read from the AMQP Channel and immediately discarded, so there is no way to retrieve it within your
callback. If you have another consumer which can handle messages with larger payloads, you can use By default, no truncation will occur. To disable truncation on a Channel that has had it enabled, pass UNIX SignalsIf you have installed PCNTL extension dispatching of signal will be handled when consumer is not processing message.
To disable this feature just define constant
DebuggingIf you want to know what's going on at a protocol level then add the following constant to your code:
BenchmarksTo run the publishing/consume benchmark type:
TestsTo successfully run the tests you need to first setup the test You can do that by running the following commands after starting RabbitMQ:
Once your environment is set up you can run your tests like this:
ContributingPlease see CONTRIBUTING for details. Using AMQP 0.8If you still want to use the old version of the protocol then you can do it by settings the following constant in your configuration code:
The default value is Providing your own autoloaderIf for some reason you don't want to use composer, then you need to have an autoloader in place fo the library classes. People have reported to use this autoloader with success. Original README:Below is the original README file content. Credits goes to the original authors. PHP library implementing Advanced Message Queuing Protocol (AMQP). The library is port of python code of py-amqplib http://barryp.org/software/py-amqplib/ It have been tested with RabbitMQ server. Project home page: http://code.google.com/p/php-amqplib/ For discussion, please join the group: http://groups.google.com/group/php-amqplib-devel For bug reports, please use bug tracking system at the project page. Patches are very welcome! Author: Vadim Zaliva <lord@crocodile.org> [ico-version]: https://img.shields.io/packagist/v/php-amqplib/php-amqplib.svg?style=flat-square [ico-license]: https://img.shields.io/badge/license-LGPL_2.1-brightgreen.svg?style=flat-square [ico-travis]: https://img.shields.io/travis/php-amqplib/php-amqplib/master.svg?style=flat-square [ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/php-amqplib/php-amqplib.svg?style=flat-square [ico-code-quality]: https://img.shields.io/scrutinizer/g/php-amqplib/php-amqplib.svg?style=flat-square [ico-downloads]: https://img.shields.io/packagist/dt/php-amqplib/php-amqplib.svg?style=flat-square [link-packagist]: https://packagist.org/packages/php-amqplib/php-amqplib [link-travis]: https://travis-ci.org/php-amqplib/php-amqplib [link-scrutinizer]: https://scrutinizer-ci.com/g/php-amqplib/php-amqplib/code-structure [link-code-quality]: https://scrutinizer-ci.com/g/php-amqplib/php-amqplib [link-downloads]: https://packagist.org/packages/php-amqplib/php-amqplib [link-author]: https://github.com/php-amqplib [link-contributors]: ../../contributors |