Download the PHP package medeiroz/laravel-amqp-toolkit without Composer

On this page you can find all versions of the php package medeiroz/laravel-amqp-toolkit. 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 laravel-amqp-toolkit

Package PHP/Laravel to manager, consume and publish messages with AMQP / RabbitMQ

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package was developed to facilitate the integration of Laravel applications with RabbitMQ, providing functionalities to consume and publish messages, in addition to providing a simple way to manage the AMQP / RabbitMQ infrastructure through schema migrations, inspired by Laravel's database migrations.

If you need to consume messages from RabbitMQ queues, publish messages in exchanges or queues, or manage the RabbitMQ infrastructure, this package is for you.

If you have a problems to manage the RabbitMQ Schema same as queues, exchanges and shovels, this package is for you.


Main Features

  1. Schema Migrations: Use schema migrations to create, delete and manage queues, exchanges and shovels in RabbitMQ, similar to what Laravel offers for databases.
  2. Consume Queue: Ability to consume messages from a RabbitMQ queue in a simple and efficient way.
  3. Publish Messages: Ability to publish messages in exchanges or directly in RabbitMQ queues.
  4. Event Listeners: Ability to listen to messages received from AMQP / RabbitMQ queues and exchanges, similar to Laravel's event listeners.

Requirements

Installation

follow the steps below to install the package:

  1. Install the medeiroz/laravel-amqp-toolkit package via composer
  2. Publish and run migrations
  3. Publish the configuration file
  4. Environment variables .env
  5. Configure the AMQP Queue and Laravel Listeners

1. Install the package

Run the command below to install the package via composer:

2. Publish migrations

You must publish the database migration with:

Then run the command below to create the table in the database.

3. Publish the configuration file

You can publish the configuration file with:

This is the content of the published configuration file:

4. Environment variables .env

Edit the .env file and add the environment variables of your AMQP / Rabbitmq server.

Remember to replace the values according to your environment.

5. Configure the AMQP Queue and Laravel Listeners

Edit the config/amqp-toolkit.php file and add the queues you want to consume and the listeners that will be executed when a message is received.

The key of the array is the name of the queue and the value is the listener class that will be executed when a message is received.

Example: Attach the listener PaymentReceivedListener to the queue payment-received

Refer to the configuration file for more details.


Usage

Schema Migrations

Allowed schema types are:

Creating a Schema

Examples

Running Migrations

Reverting Migrations

Reverting all migrations


Publishing a message to a queue or exchange


Start consuming an AMQP / RabbitMQ queue

Running the consumer for all queues

To start consuming all queues you must run the artisan command below:

To start consuming a specific queues you must run the artisan command below:

Where my-first-queue and payment-received is the name of the queues you want to consume.


Listening messages

The package provides a way to listen to messages received from AMQP / RabbitMQ queues and exchanges, similar to Laravel's event listeners.

1. Automatic listener registration

When a queue and listener are configured in the config/amqp-toolkit.php file, the listener will be automatically registered when the consumer is executed.

2. Manual listener registration

Edit the app/Providers/EventServiceProvider.php file and add the events you want to listen to.

The name of the event should be amqp.QUEUE_NAME, where QUEUE_NAME is the name of the queue you want to listen to.

app/Providers/EventServiceProvider.php

Note: The amqp:* event is a special event that listens to all messages received from all queues. The queue event is only called if the consumer is being executed

Creating a listener for the event

You can create a listener for the event you want to listen to, for this run the command below:

This package provides an event object Medeiroz\AmqpToolkit\Events\AmqpReceivedMessageEvent that contains the queue name and the message body.

If you want your events to be executed asynchronously with Laravel Horizon, you can use the ShouldQueue interface.

More about the AMQP Migration Schema

Creating an Exchange Schema

Create a new exchange schema with the command below:

Generated file:

Creating a Queue Schema

Create a new queue schema with the command below:

Generated file:

This schema creates a queue named payment-received with retry, ttl and dlq. RabbitMQ will automatically create the payment-received.retry and payment-received.dlq queues.

You can create bind the queue to an exchange by calling the bind method.

Creating a Shovel Schema

Create a new shovel schema with the command below:

Generated file:

You can create a shovel with the createShovel or createShovelIfNonExists method, passing the name of the shovel, the source and destination resources.

The source and destination are objects that represent message broker resources.

Available resources:

You create a shovel to move messages from Broker A to Broker B, for example.

More about the shovel configuration can be found in the RabbitMQ Shovel documentation.

Note: The shovel schema is only available for RabbitMQ 3.8.0 or later.

All available methods in schema migration

More about the Shovel

The shovel is a feature that allows you to move messages between different brokers, for example, RabbitMQ to Azure Service Bus, Azure Service Bus to RabbitMQ, etc.

If your message broke is Azure Service Bus and your application as code with PHP/Laravel, you can not consume messages directly from the Azure Service Bus. You can create a shovel to move messages from Azure Service Bus to RabbitMQ and consume messages from RabbitMQ.

Forward message from Azure Service Bus to RabbitMQ

You need create a specific resources for your shovel, for example, you have the resources below:


Forward message from RabbitMQ to Azure Service Bus

You need create a specific resources for your shovel, for example, you have the resources below:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-amqp-toolkit with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-sockets Version *
ext-mbstring Version *
illuminate/contracts Version ^10.0|^11.0
php-amqplib/php-amqplib Version ^3.6
spatie/laravel-package-tools Version ^1.14.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 medeiroz/laravel-amqp-toolkit contains the following files

Loading the files please wait ....