PHP code example of platformcommunity / flysystem-bunnycdn
1. Go to this page and download the library: Download platformcommunity/flysystem-bunnycdn library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
platformcommunity / flysystem-bunnycdn example snippets
use League\Flysystem\Filesystem;
use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNAdapter;
use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNClient;
use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNRegion;
$adapter = new BunnyCDNAdapter(
new BunnyCDNClient(
'storage-zone',
'api-key',
BunnyCDNRegion::FALKENSTEIN
)
);
$filesystem = new Filesystem($adapter);
$adapter = new BunnyCDNAdapter(
new BunnyCDNClient(
'storage-zone',
'api-key',
BunnyCDNRegion::FALKENSTEIN
),
'https://testing.b-cdn.net/' # Pull Zone URL
);
$filesystem = new Filesystem($adapter);
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Storage::extend('bunnycdn', function ($app, $config) {
$adapter = new BunnyCDNAdapter(
new BunnyCDNClient(
$config['storage_zone'],
$config['api_key'],
$config['region']
),
$config['pull_zone']
);
return new FilesystemAdapter(
new Filesystem($adapter, $config),
$adapter,
$config
);
});
}