PHP code example of klytron / laravel-google-drive-filesystem

1. Go to this page and download the library: Download klytron/laravel-google-drive-filesystem 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/ */

    

klytron / laravel-google-drive-filesystem example snippets


use Illuminate\Support\Facades\Storage;

// Store a file
Storage::disk('google')->put('example.txt', 'Hello, Google Drive!');

// Retrieve a file
$content = Storage::disk('google')->get('example.txt');

// List files in a directory
$files = Storage::disk('google')->files('/');

// Delete a file
Storage::disk('google')->delete('example.txt');

// Check if file exists
if (Storage::disk('google')->exists('example.txt')) {
    // File exists
}

// Get file size
$size = Storage::disk('google')->size('example.txt');

// Get last modified time
$modified = Storage::disk('google')->lastModified('example.txt');

// Create a directory (folders are created automatically when uploading files)
Storage::disk('google')->makeDirectory('uploads/images');

// List directories
$directories = Storage::disk('google')->directories('/');

// List all contents (files and folders)
$contents = Storage::disk('google')->allFiles('/');

// Delete a directory and all its contents
Storage::disk('google')->deleteDirectory('uploads/images');
bash
php artisan vendor:publish --tag=google-drive-config