asmblah/php-amqp-compat

Installs: 1 990

Dependents: 5

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 2

Type:project

v0.4.12 2024-05-29 22:31 UTC

README

PHP AMQP-Compat.

Build Status

php-amqp/ext-amqp compatibility using php-amqplib.

Why?

php-amqp/librabbitmq does not fully support AMQP heartbeats, they are only supported during blocking calls into the extension.

Heartbeat sender

With php-amqplib, we're able to send heartbeats more regularly, in multiple ways:

  1. Using a ReactPHP EventLoop with Envoylope EventLoop (recommended).
  2. Using UNIX System V signals with Envoylope ext-pcntl.

See the usage instructions for the packages above for installation.

Usage

First, remove ext-amqp - it cannot be used at the same time as this compatibility layer. Usually, this will be with PECL:

$ pecl uninstall amqp

This is because the classes installed in the global/root namespace such as AMQPConnection would conflict.

Second, install this package with Composer:

$ composer require asmblah/php-amqp-compat

Lastly, install the relevant heartbeat sender, if required.

That should be all the changes required - this userland library is designed as a drop-in replacement.

Limitations

  • Persistent connections are not and cannot be supported from userland.
  • If existing logic is checking for the amqp extension via extension_loaded('amqp'), it will fail because this library does not define an extension. During functional testing, extension_loaded(...) is hooked using PHP Code Shift to allow running tests from the reference implementation php-amqp/ext-amqp, see ReferenceImplementationTest.

See also

  • The original php-amqp extension that this compatibility layer replaces: php-amqp/ext-amqp.
  • php-amqplib, which this library uses under the hood: php-amqplib.