PHP code example of quix-labs / laravel-supabase-flysystem

1. Go to this page and download the library: Download quix-labs/laravel-supabase-flysystem 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/ */

    

quix-labs / laravel-supabase-flysystem example snippets


'supabase' => [
    'driver' => 'supabase',
    'key'    => env('SUPABASE_STORAGE_KEY'), // Use a privileged key; read-only does not work
    'bucket' => env('SUPABASE_STORAGE_BUCKET'),
    'endpoint' => env('SUPABASE_STORAGE_ENDPOINT'),

    'url'      => null, // <- Automatically generated; change here if you are using a proxy

    'public'                      => true,  // Default to true
    'defaultUrlGeneration'        => null, // 'signed' | 'public' <- default depends on public

    'defaultUrlGenerationOptions' => [
        'download'  => false,
        'transform' => [],
    ],

    'signedUrlExpires' => 60*60*24, // 1 day <- default to 1 hour (3600)
],

// Example code for using the Supabase driver with Laravel Storage
Storage::disk('supabase')->put('file.txt', 'contents');

// Custom function to generate a public URL
Storage::disk('supabase')->getAdapter()->getPublicUrl('completelyPublicFile.png', [
    'download'  => false, // Set this to true if you want the user's browser to automatically trigger download
    
    // Transform only applied if the file is detected as an image; else ignored
    'transform' => [ 
        'width' => 200,
        //... All options -> https://supabase.com/docs/guides/storage/serving/image-transformations#transformation-options
    ]]);

// Custom function to generate a signed URL
Storage::disk('supabase')->getAdapter()->getSignedUrl('veryConfidentialFile.png', [
    'expiresIn' => 60 * 5, // 5 minutes
    //... Same options as getPublicUrl
]);