PHP code example of softavis / flysystem-cloudflare

1. Go to this page and download the library: Download softavis/flysystem-cloudflare 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/ */

    

softavis / flysystem-cloudflare example snippets




declare(strict_types=1);

use League\Flysystem\Config;
use Softavis\Flysystem\Cloudflare\Client;
use Softavis\Flysystem\Cloudflare\CloudflareAdapter;
use Symfony\Component\HttpClient\HttpClient;

ARIANT_NAME = 'your-cloudflare-images-variant';

const CLOUDFLARE_URL = 'https://api.cloudflare.com/client/v4/accounts/%s/images/';

$client = new Client(HttpClient::createForBaseUri(sprintf(CLOUDFLARE_URL, CLOUDFLARE_ACCOUNT_ID), [
    'auth_bearer' => CLOUDFLARE_API_KEY,
]));

$adapter = new CloudflareAdapter($client);

$flysystem = new League\Flysystem\Filesystem($adapter, [
    'accountHash' => CLOUDFLARE_ACCOUNT_HASH,
    'variantName' => CLOUDFLARE_VARIANT_NAME
]);

// see http://flysystem.thephpleague.com/api/ for full list of available functionality