, ,

I’m a big fan of Message Queueing and in particular RabbitMQ. For some reason, support for it was not natively included in Laravel 5 and as of 5.2 its still not present.

Using Composer, its easy to add support and one library I found very useful and easy to get going was the php-amqplib which is hosted/located on github.

URL: https://github.com/videlalvaro/php-amqplib

To get it automatically installed change into your Laravel Project directory and edit the composer.json file. Add the line “videlalvaro/php-amqplib”: “2.*” as shown below:

vi composer.json

“type”: “project”,
“require”: {
“php”: “>=5.5.9”,
“laravel/framework”: “5.1.*”,
“videlalvaro/php-amqplib”: “2.*”

Save the addition and exit your editor, then run a composer update:

# composer update

The following output should appear:

Loading composer repositories with package information
Updating dependencies (including require-dev)
– Installing videlalvaro/php-amqplib (v2.0.2)
Downloading: 100%

Writing lock file
Generating autoload files
> php artisan clear-compiled
> php artisan optimize
Generating optimized class loader


For a full description of how to use it see the github project. However, there is a demo directory with lots of samples that gets installed by Composer.

You can find the demo PHP code in: <project>/vendor/videlalvaro/php-amqplib/demo

To use it inside a Laravel project, you just need to include the “use” statements in your PHP file and then make the basic AMQP calls.

Using an existing project, add a blade called mqtest.blade.php

Add a route in routes.php to call the view using a function:

Route::get(‘/mqtest’, function () {return view(‘mqtest’);

Edit the blade file and include the following, substitute you login details and RabbitMQ host as needed.

TODO – grab sample from working file


NOTE: 2016-05-24 – This library is now showing as defunct/deprecated during a “composer update” but a lot of other libraries seam to rely on it. I suggest you check the composer archive to locate a replacement suitable to your needs.