Download the PHP package chocofamilyme/laravel-pubsub without Composer

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

Laravel PubSub Library

Laravel pub/sub library allows you to publish, consume and process rabbit events.

Installation

Upgrade v6 -> v7

Read upgrade guide here

Upgrade v5 -> v6

Read upgrade guide here

Upgrade v3 -> v4

Read upgrade guide here

Publishing the configuration and migration

Configurations

AMQP (RabbitMQ) configuration

Params

Key Value Description
connection Default PhpAmqpLib\Connection\AMQPLazyConnection::class php-amqplib
options Array See - php-amqplib
options.message-ttl miliseconds Message life time
options.publisher.queue Array Publisher config
options.publisher.queue.declare false Should create queue before publishing
options.publisher.queue.bind false Should bind queue with exchange before publishing
options.publisher.exchange.declare false Should created exchange before publishing
options.publisher.exchange.name string Exchange name

Event routing configuration

Event routing configuration file is located under config/pubsub.php and contains configuration for EventRouting and storing events in database.

Usage

You can listen for RabbitMQ events and publish them.

--job=laravel flag should be used if you want to listen to inter project events but from rabbitmq queue.

--job=laravel flag should be used for intermicroservice communictaion.

Examples

Single event

Will listen to single event "gateway.user.authenticated" in default exchange and queue name. Configure the internal event routing in Event is taken from payload, when you publish the event it appends the event name automatically there.

Wildcard event

Will listen to all "gateway.user.*" events in exchange gateway and with queue name "guardqueue"

Interproject communictaion

Will listen for default laravel event, in the default case --job=laravel is set by default

php artisan event:listen flags and parameters

How to publish events

For laravel default way see the laravel documentation

https://laravel.com/

If you want to publish event to RabbitMQ

We've tried to make it easy as possible for you, see how it works:

  1. Create event with , please aware that the name of your event class will be the event name in the message payload. It is then used for internal router
  2. Open fresh created event and extends from
  3. You will have to override values of constants couple of methods like , . These constants tell the dispatcher which exchange should be used for this event and which routing key. See? It's pretty self-descriptive.
  4. Since you extended from class you could override more methods which could make the event more precise, for that please see inside this class.
  5. After our event is ready, we now can publish it in laravel way:

Since this event extends from PublishEvent class implementing SendToRabbitMQInterface, it will be sent into rabbitmq automatically.

PS: Please note that you need to override toPayload() method returning array that would be used as message payload.

Example event class

Example setting listen in config/pubsub.php

To save failed jobs, you need to make the following changes config in queue.php and set uuid column nullable in failed_jobs table


All versions of laravel-pubsub with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-json Version *
vladimir-yuldashev/laravel-queue-rabbitmq Version ^13.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 chocofamilyme/laravel-pubsub contains the following files

Loading the files please wait ....