PHPackages                             bunny-poooh/laravel-mercure-publisher - 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. [API Development](/categories/api)
4. /
5. bunny-poooh/laravel-mercure-publisher

ActiveLibrary[API Development](/categories/api)

bunny-poooh/laravel-mercure-publisher
=====================================

Laravel Mercure Publisher

1.0(5y ago)017MITPHPPHP ^7.1.3

Since Jun 30Pushed 5y agoCompare

[ Source](https://github.com/bunny-poooh/laravel-mercure-publisher)[ Packagist](https://packagist.org/packages/bunny-poooh/laravel-mercure-publisher)[ RSS](/packages/bunny-poooh-laravel-mercure-publisher/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Laravel Mercure Publisher
=========================

[](#laravel-mercure-publisher)

Laravel Mercure Publisher is a simple wrapper around the [Symfony Mercure Component](https://github.com/symfony/mercure), leveraging *Server Sent Events* with the [Mercure protocol](https://github.com/dunglas/mercure).

Installation
------------

[](#installation)

This package can be installed through Composer.

```
composer require idplus/laravel-mercure-publisher
```

The package will automatically register its service provider.

Out of the box, you can define the "Mercure Hub Url" and his "JWT Secret" via Environment Variable in your `.env` file:

```
...
MERCURE_PUBLISH_URL=http://127.0.0.1:3000/hub
MERCURE_JWT_SECRET=your.token.here
```

Optionally, you can publish the entire config file to `config/mercure.php` with this command:

```
php artisan vendor:publish --provider="Idplus\Mercure\MercureServiceProvider"
```

Here is the default contents of the configuration file:

```
return [
    'hub' => [
        'url' => env('MERCURE_PUBLISH_URL','http://127.0.0.1:3000/hub'),
        'jwt' => env('MERCURE_JWT_SECRET'),
    ],
    'jwt_provider' => null,
    'queue_name' => null,
];
```

Usage
-----

[](#usage)

First, make sure you have [Mercure](https://github.com/dunglas/mercure) installed and running.

### Publishing

[](#publishing)

The `Symfony Mercure Component` loaded with this package provides an Update value object representing the update to publish. You can then use the `Publify` service to dispatch updates to the Hub.

The `Publify` service can be injected using dependency injection in any other services or controllers:

```
