Download the PHP package m6web/amqp-bundle without Composer

On this page you can find all versions of the php package m6web/amqp-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package amqp-bundle

AmQPBundle

Build Status Total Downloads License PHP Version Require

The configuration and documentation are inspired from videlalvaro/RabbitMqBundle.

Amqp client as a Symfony Service

The AmqpBundle incorporates messaging in your application using the php-amqp extension. It can communicate with any AMQP spec 0-9-1 compatible server, such as RabbitMQ, OpenAMQP and Qpid, giving you the ability to publish to any exchange and consume from any queue.

Publishing messages to AMQP Server from a Symfony controller is as easy as:

When you want to consume a message out of a queue:

The AmqpBundle does not provide a daemon mode to run AMQP consumers and will not. You can do it with the M6Web/DaemonBundle.

Installation

Use composer:

Then make sure the bundle is registered in your application:

Usage

Add the m6_web_amqp section in your configuration file.

By default, the Symfony event dispatcher will throw an event on each command (the event contains the AMQP command and the time used to execute it). To disable this feature, as well as other events' dispatching:

Here a configuration example:

Here we configure the connection service and the message endpoints that our application will have.

Producer and Consumer services are retrievable using m6_web_amqp.locator using getConsumer and getProducer.

In this example your service container will contain the services m6_web_amqp.producer.myproducer and m6_web_amqp.consumer.myconsumer.

Producer

A producer will be used to send messages to the server.

Let's say that you want to publish a message and you've already configured a producer named myproducer (just like above), then you'll just have to inject the m6_web_amqp.producer.myproducer service wherever you wan't to use it:

Otherwise, you could use m6_web_amqp.locator

In the AMQP Model, messages are sent to an exchange, this means that in the configuration for a producer you will have to specify the connection options along with the exchange_options.

If you need to add default publishing attributes for each message, publish_attributes options can be something like this:

If you don't want to use the configuration to define the routing key (for instance, if it should be computed for each message), you can define it during the call to publishMessage():

Consumer

A consumer will be used to get a message from the queue.

Let's say that you want to consume a message and you've already configured a consumer named myconsumer (just like above), then you'll just have to inject the m6_web_amqp.consumer.myconsumer service wherever you wan't to use it:

Otherwise, you could use m6_web_amqp.locator

The consumer does not wait for a message: getMessage will return null immediately if no message is available or return a AMQPEnvelope object if a message can be consumed. The "flags" argument of getMessage accepts AMQP_AUTOACK (auto acknowledge by default) or AMQP_NOPARAM (manual acknowledge).

To manually acknowledge a message, use the consumer's ackMessage/nackMessage methods with a delivery_tag argument's value from the AMQPEnvelope object. If you choose to not acknowledge the message, the second parameter of nackMessage accepts AMQP_REQUEUE to requeue the message or AMQP_NOPARAM to forget it.

Be careful with qos parameters, you should know that it can hurt your performances. Please read this. Also be aware that currently there is no global parameter available within PHP amqp extension.

Lazy connections

It's highly recommended to set all connections to in the configuration file. It'll prevent the bundle from connecting to RabbitMQ on each request.

If you want lazy connections, you have to add to your composer.json file, and (as said before) add to your connections.

DataCollector

DataCollector is enabled by default if kernel.debug is true. Typically in the dev environment.

Docker

If you have a multi-containers apps, we provide a Dockerfile for a container with rabbitmq-server. This container is for testing only.

Example of docker-compose.yml:

Testing

If you use this library in your application tests you will need rabbitmq instance running. If you don't want to test rabbitmq producers and consumers you can enable sandbox mode:

In this mode there will be no connection established to rabbitmq server. Producers silently accept message, consumers silently assume there are no messages available.


All versions of amqp-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-amqp Version >=2.0
symfony/dependency-injection Version ^5.4 || ^6.4 || ^7.0
symfony/framework-bundle Version ^5.4 || ^6.4 || ^7.0
symfony/http-kernel Version ^5.4 || ^6.4 || ^7.0
symfony/yaml Version ^5.4 || 6.4 || ^7.0
twig/twig Version ^2.13 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package m6web/amqp-bundle contains the following files

Loading the files please wait ....