Download the PHP package mallardduck/dynamic-echo-events without Composer
On this page you can find all versions of the php package mallardduck/dynamic-echo-events. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mallardduck/dynamic-echo-events
More information about mallardduck/dynamic-echo-events
Files in mallardduck/dynamic-echo-events
Package dynamic-echo-events
Short Description A library that allows registering laravel-echo events dynamically and done entirely in PHP.
License MIT
Homepage https://github.com/mallardduck/dynamic-echo-events
Informations about the package dynamic-echo-events
Dynamic Echo Events
A helper library to dynamically generate the javascript to register Echo event listeners.
Instead of manually writing JS code to register Echo event listeners, simply define the JS handler callback in the Event.
Then add the ImplementsDynamicEcho
contact and use the PrivateDynamicEchoChannel
trait.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Usage
First, you will need to make sure that your site's app.js
file properly configures the Echo javascript client.
This ensures the generated code has the necessary requirements.
Then, modify your sites base theme files to load the dynamic echo generated javascript.
This should be done at a point in the template where the main app.js
is loaded.
Add in:
Finally, when you want an event to automatically register itself in the browser use the Event contact and trait.
This is done simply by adding the ImplementsDynamicEcho
contact and use the PrivateDynamicEchoChannel
trait to the event.
Check the examples
folder for working example(s) of how this is done.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
- mallardduck
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of dynamic-echo-events with dependencies
ext-json Version *
composer/composer Version ^2.0
illuminate/contracts Version ^7.0|^8.0