motomedialab/bunny
Composer 安装命令:
composer require motomedialab/bunny
包简介
An integration with BunnyCDN to upload and check on the status of streamed videos
README 文档
README
This is an expanding library of bunny.net integrations developed by MotoMediaLab. Currently, it only supports uploading of videos via the Bunny Stream fetch method and some basic integration around this. As our requirements expand, this package will be updated with new functionality.
Installation
Installation can be achieved quickly and easily using Composer:
composer require motomedialab/bunny
Configuration
Below are the configuration parameters for Bunny Stream:
# library ID that videos should be uploaded to BUNNY_STREAM_LIBRARY_ID=12345 # the CDN hostname for your stream configuration BUNNY_STREAM_HOSTNAME=vz-xyz.b-cdn.net # the API key for bunny stream (this is different from your account API key!) BUNNY_STREAM_API_KEY=YOUR_API_KEY
Uploading a video
This library consolidates the process of uploading a video into a series of jobs. To upload a video, you need the URL of the video location and a title at a minimum.
// invokable class to trigger an upload job app()->call(\Motomedialab\Bunny\Actions\UploadVideoFromUrl::class, [ 'url' => 'https://example.com/file.mp4', 'title' => 'The video title' ]);
The Upload Flow
The upload process is designed to be entirely asynchronous, leveraging Laravel's queueing system.
When you call the UploadVideoFromUrl invokable action, the following steps are initiated:
- An
UploadVideoFromUrljob is dispatched to the queue. - When the job is processed, it makes an API call to Bunny.net, instructing it to fetch the video from the specified URL.
- If the API call fails for any reason, a
VideoUploadFailedevent is dispatched and the process ends. - On success, a
CheckVideoTranscodingProgressjob is dispatched to the queue with a 2-minute delay. This is to give Bunny.net time to start the transcoding process. - The
CheckVideoTranscodingProgressjob will then:- Fire a
VideoTranscodingevent with the current progress of the transcoding. - If the transcoding is finished, a
VideoTranscodingFinishedevent is fired. - If the transcoding fails, a
VideoTranscodingFailedevent is fired. - If the initial upload failed, a
VideoUploadFailedevent is fired. - If the video is still transcoding, the job will re-dispatch itself with a 30-second delay.
- Fire a
This cycle will continue until the video has finished transcoding or an error occurs.
Events
This package fires several events throughout the upload and transcoding process, allowing you to hook into the workflow and react accordingly.
Motomedialab\Bunny\Events\VideoTranscoding
This event is fired each time the CheckVideoTranscodingProgress job runs and the video is still transcoding. It provides the current progress of the transcoding, allowing you to display a progress bar or other feedback to the user.
Motomedialab\Bunny\Events\VideoTranscodingFinished
Once the video has been successfully transcoded, this event is fired. This is the point where you would typically update your database, associate the video with a model, and make it available to your users.
Motomedialab\Bunny\Events\VideoTranscodingFailed
If the transcoding process fails for any reason, this event will be fired. You can inspect the $event->video->transcodingMessages() to get more information on the type of failure.
Motomedialab\Bunny\Events\VideoUploadFailed
This event is dispatched if the initial upload fails. This can happen for a variety of reasons, such as an invalid URL or an API error. The event will contain the API error or video object where applicable, along with any metadata you passed.
Metadata
To track your conversion job throughout the process, we recommend sending metadata. This is shared throughout the workflow so you can react to the events later on.
// dispatch job with metadata app()->call(\Motomedialab\Bunny\Actions\UploadVideoFromUrl::class, [ 'url' => 'https://example.com/file.mp4', 'title' => 'The video title', 'metadata' => [ 'model' => 'App\Models\Post', 'model_id' => 12, ] ]); // listen for the transcoding finished event class VideoTranscodingListener { public function __construct(\Motomedialab\Bunny\Events\VideoTranscodingFinished $event) { if ($event->metadata('model') === 'App\Models\Post') { // ToDo: find your post and assign the video... } } }
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
motomedialab/bunny 适用场景与选型建议
motomedialab/bunny 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 295 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bunnyCDN」 「motomedialab」 「bunny-stream」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 motomedialab/bunny 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 motomedialab/bunny 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 motomedialab/bunny 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A helper method to generate absolute asset URL's to Vite assets
BunnyNet API client for PHP
PHP library to interact with the BunnyCDN Storage API.
A simple audit helper that integrates directly with Laravel & FilamentPHP
Generate self-healing URLs for models
Store data to be shared across application for the duration of the applications runtime
统计信息
- 总下载量: 295
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 38
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-16