PHPackages                             chocofamilyme/laravel-pubsub - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. chocofamilyme/laravel-pubsub

ActiveLibrary[Queues &amp; Workers](/categories/queues)

chocofamilyme/laravel-pubsub
============================

AMQP wrapper for Laravel to publish and consume messages

10.2.1(1y ago)1020.3k↑16.1%6[2 issues](https://github.com/chocofamilyme/laravel-pubsub/issues)BSD-3-ClausePHPPHP ^8.0CI failing

Since Oct 30Pushed 1y ago5 watchersCompare

[ Source](https://github.com/chocofamilyme/laravel-pubsub)[ Packagist](https://packagist.org/packages/chocofamilyme/laravel-pubsub)[ RSS](/packages/chocofamilyme-laravel-pubsub/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (5)Versions (65)Used By (0)

Laravel PubSub Library
======================

[](#laravel-pubsub-library)

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

Installation
============

[](#installation)

```
composer require chocofamilyme/laravel-pubsub
```

Upgrade v6 -&gt; v7
===================

[](#upgrade-v6---v7)

Read upgrade guide [here](https://github.com/chocofamilyme/laravel-pubsub/blob/master/docs/UPGRADE.md)

Upgrade v5 -&gt; v6
===================

[](#upgrade-v5---v6)

Read upgrade guide [here](https://github.com/chocofamilyme/laravel-pubsub/blob/master/docs/UPGRADE.md)

Upgrade v3 -&gt; v4
===================

[](#upgrade-v3---v4)

Read upgrade guide [here](https://github.com/chocofamilyme/laravel-pubsub/blob/master/docs/UPGRADE.md)

Publishing the configuration and migration
==========================================

[](#publishing-the-configuration-and-migration)

```
php artisan vendor:publish --provider="Chocofamilyme\LaravelPubSub\Providers\PubSubServiceProvider"
```

Configurations
==============

[](#configurations)

AMQP (RabbitMQ) configuration
-----------------------------

[](#amqp-rabbitmq-configuration)

- Set environment BROADCAST\_DRIVER = rabbitmq
- Add to config/broadcasting.php rabbitmq driver

```
...
'connections' => [
        'rabbitmq' => [
            'driver' => 'rabbitmq',
        ],
...
]
```

- AMQP configuration should be inserted into config/queue.php

```
'sync' => [
...
],

'database' => [
...
],

'beanstalkd' => [
...
],

// Insert into your config/queue.php
'rabbitmq' => [
    'driver' => 'rabbitmq',
    'queue' => env('RABBITMQ_QUEUE', 'default'),
    'connection' => PhpAmqpLib\Connection\AMQPSocketConnection::class,
    'worker' => env('RABBITMQ_WORKER', Chocofamilyme\LaravelPubSub\Queue\RabbitMQQueue::class),

    'hosts' => [
        [
        'host' => env('SERVICE_RABBITMQ_HOST', '127.0.0.1'),
        'port' => env('SERVICE_RABBITMQ_PORT', 5672),
        'user' => env('SERVICE_RABBITMQ_USER', 'guest'),
        'password' => env('SERVICE_RABBITMQ_PASSWORD', 'guest'),
        'vhost' => env('SERVICE_RABBITMQ_VHOST', '/'),
        ],
     ],

    'options' => [
        'ssl_options' => [
            'cafile' => env('RABBITMQ_SSL_CAFILE', null),
            'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
            'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
            'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', true),
            'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
        ],

        'heartbeat' => 60,
        'message-ttl' => 60000000,

        'publisher' => [
            'queue' => [
                'declare' => false,
                'bind' => false,
            ],
            'exchange' => [
                'declare' => false,
                'name' => 'exchange-name',
            ],
        ],
    ],
]
```

### Params

[](#params)

KeyValueDescriptionconnectionDefault PhpAmqpLib\\Connection\\AMQPLazyConnection::class[php-amqplib](https://github.com/php-amqplib/php-amqplib/tree/master/PhpAmqpLib/Connection)optionsArraySee - [php-amqplib](https://github.com/php-amqplib/php-amqplib)options.message-ttlmilisecondsMessage life timeoptions.publisher.queueArrayPublisher configoptions.publisher.queue.declarefalseShould create queue before publishingoptions.publisher.queue.bindfalseShould bind queue with exchange before publishingoptions.publisher.exchange.declarefalseShould created exchange before publishingoptions.publisher.exchange.namestringExchange nameEvent routing configuration
---------------------------

[](#event-routing-configuration)

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

```
