asmblah / php-amqp-compat
Installs: 3 539
Dependents: 5
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 2
Type:project
Requires
- php: >=8.1
- ext-sockets: *
- nytris/nytris: ^0.1
- php-amqplib/php-amqplib: v3.5.4
- psr/log: ^1|^2|^3
Requires (Dev)
- asmblah/php-code-shift: ^0.1.0
- mockery/mockery: ^1.6
- phpstan/phpstan: ^1.10
- phpstan/phpstan-mockery: ^1.1
- phpunit/phpunit: ^10.2
- tasque/event-loop: ^0.1
- tasque/tasque: ^0.1
Provides
- ext-amqp: *
README
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:
- Using a ReactPHP EventLoop with Envoylope EventLoop (recommended).
- 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 viaextension_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.