Download the PHP package bunny-poooh/laravel-mercure-publisher without Composer

On this page you can find all versions of the php package bunny-poooh/laravel-mercure-publisher. 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-mercure-publisher

Laravel Mercure Publisher

Laravel Mercure Publisher is a simple wrapper around the Symfony Mercure Component, leveraging Server Sent Events with the Mercure protocol.

Installation

This package can be installed through Composer.

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:

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

Here is the default contents of the configuration file:

Usage

First, make sure you have Mercure installed and running.

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:

Subscribing

In your frontend blade view you can subscribe to updates in JavaScript like this:

Advanced usage

Delegate the JWT generation to your custom service

Instead of directly storing a JWT in the configuration, you can create a service that will return a customized token:

You need to reference this class in the config/mercure.php configuration file:

Async dispatching

By default, Updates sent with the Publify service are synchronous.

You can dispatch the updates asynchronously using Laravel Queue. You just have to fill the queue_name variable in the Mercure configuration file. For example, you can use 'default' or 'high'.

Don't forget to run php artisan queue:work beforehand.

Mercure Hub Auto-Discovery

This packege auto-register the mercure.discover Middleware. You can use it on your subscribes routes to inject the URL of the Mercure Hub in a Link HTTP header.

The hub URL can be automatically discovered:

References

You should also try Laravel Mercure Broadcaster for another type of implementation.

License

This package is published under the MIT License (MIT).


All versions of laravel-mercure-publisher with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1.3
symfony/mercure Version ^0.4.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 bunny-poooh/laravel-mercure-publisher contains the following files

Loading the files please wait ....