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 :)
You can install the package via composer:
composer require denitsa-md/laravel-progress-status-broadcast
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.
Tests coming soon...
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email dmlechkova@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.