Skip to content

FiveLab/Amqp

Repository files navigation

Russia has become a terrorist state.

 #StandWithUkraine 

Event Broker: AMQP

Build Status

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/