denitsa-md / laravel-progress-status-broadcast
Broadcast progress status (percentage) of a long-running task.
Requires
- php: ^7.4
- illuminate/broadcasting: ^7
- illuminate/support: ^7
Requires (Dev)
- orchestra/testbench: ^5.0
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2025-02-15 04:13:09 UTC
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.