PHP code example of taffovelikoff / imagekit-adapter

1. Go to this page and download the library: Download taffovelikoff/imagekit-adapter 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/ */

    

taffovelikoff / imagekit-adapter example snippets


use ImageKit\ImageKit;
use League\Flysystem\Filesystem;
use TaffoVelikoff\ImageKitAdapter\ImageKitAdapter;

// Client
$client = new ImageKit (
    'your_public_key',
    'your_private_key',
    'your_endpoint_url' // Should look something like this https://ik.imagekit.io/qvkc...
);

// Adapter
$adapter = new ImagekitAdapter($client);

// Filesystem
$fsys = new Filesystem($adapter);

// Check if file exists example
$file = $fsys->fileExists('default-image.jpg');

$adapter = new ImagekitAdapter($client, $options = [
    'purge_cache_update'    => [
        'enabled'       => true,
        'endpoint_url'  => 'your_endpoint_url'
    ]
]);

public function boot()
{
    Storage::extend('imagekit', function ($app, $config) {
        $adapter = new ImagekitAdapter(

            new ImageKit(
                $config['public_key'],
                $config['private_key'],
                $config['endpoint_url']
            ),

            $options = [ // Optional
                'purge_cache_update'    => [
                    'enabled'       => true,
                    'endpoint_url'  => 'your_endpoint_url'
                 ]
            ] 

        );

        return new FilesystemAdapter(
            new Filesystem($adapter, $config),
            $adapter,
            $config
        );
    });
}

'imagekit' => [
    'driver' => 'imagekit',
    'public_key' => env('IMAGEKIT_PUBLIC_KEY'),
    'private_key' => env('IMAGEKIT_PRIVATE_KEY'),
    'endpoint_url' => env('IMAGEKIT_ENDPOINT_URL')
],

IMAGEKIT_PUBLIC_KEY = your-public-key
IMAGEKIT_PRIVATE_KEY = your-private-key
IMAGEKIT_ENDPOINT_URL = your-endpint-url

Storage::disk('imagekit')->put('test.txt', 'This is a test file.');

return response(Storage::disk('imagekit')->get('test.txt'));

return [
    'purge_cache_update'    => true,
    'extend_storage'        => true,
];