denitsa-md / laravel-progress-status-broadcast
广播长时间运行任务的进度状态(百分比)。
0.1.0
2020-07-14 16:38 UTC
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: 2024-09-15 03:08:42 UTC
README
我需要一些简单的功能来广播进度事件(10%、20% ... 100% 完成),当应用程序中发生长时间运行的操作时。
这也是我在 Packagist 上发布的第一个包 :)
安装
您可以通过 composer 安装此包
composer require denitsa-md/laravel-progress-status-broadcast
用法
这是我们如何在项目中使用此包的示例,除了我将其与分块集合相关联之外。
导入外观 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. });
这将通过您配置的广播驱动程序发送 ProgressEvent
。
测试
即将推出...
composer test
变更日志
请参阅 CHANGELOG 了解最近更改的更多信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全
如果您发现任何安全问题,请通过电子邮件 dmlechkova@gmail.com 联系,而不是使用问题跟踪器。
鸣谢
许可证
MIT 许可证(MIT)。请参阅 许可证文件 了解更多信息。
Laravel Package Boilerplate
此包是使用 Laravel Package Boilerplate 生成的。