Skip to content

tinect/flysystem-bunnycdn-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bunny CDN Logo

Flysystem Adapter for BunnyCDN Storage

Build Status - Flysystem v2 Build Status - Flysystem v3
Codecov Packagist Version Minimum PHP Version: 7.4 Licence: MIT Downloads

Logo for SLA Timer

Installation

To install flysystem-bunnycdn, require the package with no version constraint. This should match the flysystem-bunnycdn version with your version of FlySystem (v2, v3 etc).

composer require platformcommunity/flysystem-bunnycdn "*"

Usage

use BunnyCDN\Storage\BunnyCDNClient;
use League\Flysystem\Filesystem;
use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNAdapter;
use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNRegion;

$adapter = new BunnyCDNAdapter(
    new BunnyCDNClient(
        'storage-zone', 
        'api-key', 
        BunnyCDNRegion::FALKENSTEIN
    )
);

$filesystem = new Filesystem($adapter);

Usage with Pull Zones

To have BunnyCDN adapter publish to a public CDN location, you have to a "Pull Zone" connected to your BunnyCDN Storage Zone. Add the full URL prefix of your Pull Zone (including http:///https://) to the BunnyCDNAdapter parameter like shown below.

use BunnyCDN\Storage\BunnyCDNClient;
use League\Flysystem\Filesystem;
use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNAdapter;
use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNRegion;

$adapter = new BunnyCDNAdapter(
    new BunnyCDNClient(
        'storage-zone',
        'api-key',
        BunnyCDNRegion::FALKENSTEIN
    ),
    'https://testing.b-cdn.net/' # Pull Zone URL
);
$filesystem = new Filesystem($adapter);

Note: You can also use your own domain name if it's configured in the pull zone.

Once you add your pull zone, you can use the ->getUrl($path), or in Laravel, the ->url($path) command to get the fully qualified public URL of your BunnyCDN assets.

Usage in Laravel 9

For a guide on how to use flysystem-bunnycdn in Laravel 9, follow the guide here:
https://blog.sinn.io/bunny-net-php-flysystem-v3/#usage-in-laravel-9

Regions

For a full region list, please visit the BunnyCDN API documentation page.

flysystem-bunnycdn also comes with constants for each region located within PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNRegion.

List of Regions

# Europe
BunnyCDNRegion::FALKENSTEIN = 'de';
BunnyCDNRegion::STOCKHOLM = 'se';

# United Kingdom
BunnyCDNRegion::UNITED_KINGDOM = 'uk';

# USA
BunnyCDNRegion::NEW_YORK = 'ny';
BunnyCDNRegion::LOS_ANGELAS = 'la';

# SEA
BunnyCDNRegion::SINGAPORE = 'sg';

# Oceania
BunnyCDNRegion::SYDNEY = 'syd';

Contributing

Pull requests welcome. Please feel free to lodge any issues as discussion points.

Licence

The Flysystem adapter for Bunny.net is licensed under MIT.

About

A FlySystem adapter for BunnyCDN's storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%