denitsa-md/laravel-progress-status-broadcast
Composer 安装命令:
composer require denitsa-md/laravel-progress-status-broadcast
包简介
Broadcast progress status (percentage) of a long-running task.
README 文档
README
I needed some simple functionality to broadcast progress events (10%, 20% ... 100% complete) when a long-running action was happening in the app.
This is also my first published package on packagist :)
Installation
You can install the package via composer:
composer require denitsa-md/laravel-progress-status-broadcast
Usage
This is how I've used the package in our project, except I used it in relation to a chunked collection.
Import the facade use DenitsaCm\ProgressStatusBroadcast\Facades\ProgressStatusBroadcast;
$products = Product::all(); ProgressStatusBroadcast::broadcastOn(new PrivateChannel('some-channel')) // Specify the channel ->broadcastAs('products.process') // Specify the event name ->total($products->count()); // Set the total amount so progress can be calcualted $products->each(function ($product, $key) { $product->doSomething(); ProgressStatusBroadcast::progress($key + 1); // Give the current item count to the progress status. Here I give it a +1 since the $key is 0-based and I want the progress to start from 1. });
This will send a ProgressEvent via your configured broadcast driver.
Testing
Tests coming soon...
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email dmlechkova@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.
统计信息
- 总下载量: 681
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-14