modularavel/larabunny

Use Bunny Stream Filesystem Adapter for Laravel application

1.0.0 2025-05-02 23:31 UTC

This package is auto-updated.

Last update: 2025-05-05 17:47:04 UTC


README

Bunny Stream for Laravel

This is Laravel Filesystem's Driver for simple integration with Laravel.

Installation

composer require modularavel/larabunny

Configuration

This package automatically register the service provider and the storage disk for the driver larabunny. You can configure the disk in config/filesystems.php:

'larabunny' => [
    'driver' => 'larabunny',
    'hostname' => env('MODULARAVEL_LARABUNNY_HOSTNAME'),
    'library_id' => env('MODULARAVEL_LARABUNNY_LIBRARY_ID'),
    'api_key' => env('MODULARAVEL_LARABUNNY_API_KEY'),
],

and remember to add the environment variables in your .env file:

MODULARAVEL_LARABUNNY_HOSTNAME=your-stream-cdn.b-cdn.net
MODULARAVEL_LARABUNNY_API_KEY=your-api-key
MODULARAVEL_LARABUNNY_LIBRARY_ID=123456

Usage

$videoId = Storage::disk('larabunny')->put('abc.mp4', file_get_contents('abc.mp4'));
// $videoId = guid from bunny.

 // Enable Direct File Access from Bunny to Access m3u8
return response(Storage::disk('larabunny')->get("$videoId/playlist.m3u8"));

Extra Methods

Method Description
get($path) By default returns playlist.m3u8's content, but you can customize it by adding suffix like "$path/playlist.m3u8", "$path/play_240p.mp4" and more.
getHls($path) Returns playlist.m3u8's content, which would be the main entrypoint for any HLS player.
getOriginal($path) As the name suggests, it just returns the original file's content user had uploaded initially
getMp4($path, $quality = '240p,360p,etc') Returns Mp4 file's content, $quality param allows you to customize which file you want, such 240p, 360p, 720p, NOTE: all the quality might not be available depending on the Original file's quality
getMp4($path, $quality = 'low,mid,high') Not recommended to be called in N+1 situation, as this requires API to resolve what resolution is the low, and what is high, mid, etc.