odolbeau/amqp-service-provider

This package is abandoned and no longer maintained. No replacement package was suggested.

AMQP Service Provider for Pimple

v1.0.1 2014-08-31 21:10 UTC

This package is auto-updated.

Last update: 2023-12-27 11:27:10 UTC


README

Build Status

Installation

The recommended way to install this bundle is through Composer. Require the odolbeau/amqp-service-provider package into your composer.json file:

{
    "require": {
        "odolbeau/amqp-service-provider": "@stable"
    }
}

Protip: you should browse the odolbeau/amqp-service-provider page to choose a stable version to use, avoid the @stable meta constraint.

Usage

Register the service provider (see doc for more informations).

use Pimple\Container;
use Bab\Provider\AMQPServiceProvider;

// Create a new container
$container = new Container();

// Add some configuration
$container['amqp.options'] = [
    'connections' => [
        'conn1' => [
            'host' => '127.0.0.1',
            'port' => 5672,
            'login' => 'guest',
            'password' => 'guest',
            'vhost' => '/',
        ],
        'conn2' => [
            'host' => '127.0.0.1',
            'port' => 5672,
            'login' => 'guest',
            'password' => 'guest',
            'vhost' => 'another_vhost',
        ]
    ]
];

// Register the service provider
$container->register(new AMQPServiceProvider());

You can now retrieve queues and / or exchanges like this :

// To get a queue
$container['queue.factory']('queueName', 'conn1');
// To get an exchange
$container['exchange.factory']('queueName', 'conn2');