mallardduck/dynamic-echo-events
Composer 安装命令:
composer require mallardduck/dynamic-echo-events
包简介
A library that allows registering laravel-echo events dynamically and done entirely in PHP.
关键字:
README 文档
README
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:
composer require mallardduck/dynamic-echo-events
You can publish the config file with:
php artisan vendor:publish --provider="MallardDuck\DynamicEcho\DynamicEchoServiceProvider" --tag="config"
This is the contents of the published config file:
return [ 'namespace' => env('DYNAMIC_ECHO_NS', 'App\\Events') ];
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:
@dynamicEcho
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
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-14