PHP code example of alies-dev / laravel-supabase-flysystem
1. Go to this page and download the library: Download alies-dev/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/ */
alies-dev / laravel-supabase-flysystem example snippets
'supabase' => [
'driver' => 'supabase',
'key' => env('SUPABASE_STORAGE_KEY'),
'bucket' => env('SUPABASE_STORAGE_BUCKET'),
'endpoint' => env('SUPABASE_STORAGE_ENDPOINT'),
// Optional configuration
'url' => env('SUPABASE_STORAGE_URL'), // Custom URL for public access
'public' => env('SUPABASE_STORAGE_PUBLIC', false), // Set to true for public buckets
'signed_url_ttl,' => 60 * 60 * 24, // Default TTL for signed URLs (1 day)
'url_options' => [], // Default URL generation options supported by Supabase Storage (download, transform)
],
// Store a file
Storage::disk('supabase')->put('path/to/file.jpg', $contents);
// Check if a file exists
if (Storage::disk('supabase')->exists('path/to/file.jpg')) {
// File exists
}
// Get file contents
$contents = Storage::disk('supabase')->get('path/to/file.jpg');
// Delete a file
Storage::disk('supabase')->delete('path/to/file.jpg');
// Copy a file
Storage::disk('supabase')->copy('original.jpg', 'copy.jpg');
// Move/rename a file
Storage::disk('supabase')->move('old-name.jpg', 'new-name.jpg');
// Get a URL (signed or public based on configuration)
$url = Storage::disk('supabase')->url('path/to/file.jpg');
// Get a signed URL with default options
$signedUrl = Storage::disk('supabase')->temporaryUrl(
'path/to/file.jpg',
now()->addHour()
);
// Get a signed URL with custom transform options
$transformedUrl = Storage::disk('supabase')->url('path/to/file.jpg', [
'transform' => [
'width' => 100,
'height' => 100,
'format' => 'webp',
]
]);
// Get a signed URL with a download option
$downloadUrl = Storage::disk('supabase')->url('path/to/file.jpg', [
'download' => true,
]);
// Create a directory
Storage::disk('supabase')->makeDirectory('path/to/directory');
// Delete a directory and all its contents
Storage::disk('supabase')->deleteDirectory('path/to/directory');
// List contents of a directory
$files = Storage::disk('supabase')->files('path/to/directory');
$directories = Storage::disk('supabase')->directories('path/to/directory');
// List all files recursively
$allFiles = Storage::disk('supabase')->allFiles('path/to/directory');
// Get file size
$size = Storage::disk('supabase')->size('path/to/file.jpg');
// Get file mime type
$mimeType = Storage::disk('supabase')->mimeType('path/to/file.jpg');
// Get file last modified timestamp
$lastModified = Storage::disk('supabase')->lastModified('path/to/file.jpg');