fivelab / amqp
The library for publish/receive messages from broker (RabbitMQ).
Installs: 21 849
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 1
Open Issues: 1
Requires
- php: ^8.2
Requires (Dev)
- ext-amqp: *
- ext-sockets: *
- escapestudios/symfony2-coding-standard: ~3.5
- fivelab/ci-rules: dev-master
- fivelab/transactional: ~2.0
- guzzlehttp/guzzle: ~6.5.6
- php-amqplib/php-amqplib: ^3.5
- phpmetrics/phpmetrics: ~2.7
- phpstan/phpstan: ~1.11.0
- phpunit/phpunit: ~10.1
- psr/log: *
- ramsey/uuid: ~4.7
- symfony/console: ~5.4 | ~6.0
Suggests
- ext-amqp: For use amqp extension.
- ext-sockets: For php-amqplib
- fivelab/transactional: For use transactional layer with this wrapper.
- php-amqplib/php-amqplib: pure PHP driver
- ramsey/uuid: For use UUID message id generator
- symfony/console: For configure console commands for run consumer.
README
#StandWithUkraineEvent Broker: AMQP
This library for receive events from RabbitMQ and publish messages to AMQP.
Why this?
In many application we must use background processes for process any data or create/update/delete any entries. For this, we use AMQP and RabbitMQ. But, in base implementation of AMQP (PHP Extension and PHPAmqpLib) we have some problems:
- We should connect to RabbitMQ before create the exchange or queue. But in our logic (in controller as an example) we don't need to send message rabbitmq.
- All options for declare exchanges or queues set as flags, and it can be difficult for understanding and typos.
We full isolate this processes in this library for easy send message to exchange and easy receive the messages from queues.
Definitions
All entries of AMQP have a custom definition. Each definition have custom parameters for declare the exchange or queue.
Factories
All entries of AMQP have a factory. It allow to create the real instances only on usage process.
Adapters
We create a library with able to support any adapters for connect to broker. Out-of-the-box supported drivers are:
ext-amqp
- composer php-amqplib
Documentation
All documentation stored in /docs/
directory.
Development
For easy development you can use the Docker
.
Note: We use internal network for link the our library with rabbitmq for testing and development.
docker network create --driver bridge amqp docker run -d --rm \ --network amqp \ --name amqp-rabbitmq \ rabbitmq:management docker build -t amqp . docker run -it --rm \ --name amqp \ -v $(pwd):/code \ --network amqp \ -e "RABBITMQ_HOST=amqp-rabbitmq" \ amqp bash
Note for debugging you can expose 15672 port for access to management plugin.
After success run and attach to container you must install vendors:
composer update
Before create the PR or merge into develop, please run next commands for validate code:
./bin/phpunit ./bin/phpcs --config-set show_warnings 0 ./bin/phpcs --standard=vendor/escapestudios/symfony2-coding-standard/Symfony/ src/ ./bin/phpcs --standard=tests/phpcs-ruleset.xml tests/