{"repo":"mvanduijker/laravel-mercure-broadcaster","free":true,"listed":false,"github":"https://github.com/mvanduijker/laravel-mercure-broadcaster","clone":"git clone https://github.com/mvanduijker/laravel-mercure-broadcaster.git","description":"Laravel broadcaster for Mercure","language":"PHP","stars":174,"topics":["mercure","laravel","broadcaster","php"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Laravel Mercure Broadcaster Laravel broadcaster for Mercure for doing Server Sent Events in a breeze. Installation Make sure you have installed Mercure and have it running. Check their docs how to do it. (It's pretty easy) Install the package via Composer: Configure laravel to use the Mercure broadcaster by editing config/broadcasting.php for example: Usage Add an event which implements ShouldBroadcast interface like in https://laravel.com/docs/master/broadcasting#defining-broadcast-events In your frontend do something like: Private channels go a bit differently than with broadcasting through sockets. Private channels are baked in Mercure and are secured with a jwt token. First create a http middleware, so we can generate the Mercure authentication cookie with the token. Don't forget to add the middleware to your route! Example: Because Laravel encrypts and decrypts cookies by default, don't forget to add an exception for the mercureAuthorization cookie in App\\Http\\Middleware\\EncryptCookies . Example event: Example Frontend: Advanced usage If you want to generate your own JWT, you can do it by overriding the mvanduijker.mercure broadcaster.publisher jwt service. You want to do this if you want to have custom claims, using other signing algorithms, etc. It expects a string back containing the JWT. Example how the default JWT is generated: https://github.com/mvanduijker/laravel-mercure-broadcaster/blob/master/src/LaravelMercureBroadcasterServiceProvider.php#L32 Make sure you al","default_branch":null,"files":null,"tree":[],"storefront":"/r/mvanduijker","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/mvanduijker/laravel-mercure-broadcaster/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}