PHP code example of private-it / flysystem-google-drive

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

    

private-it / flysystem-google-drive example snippets


[
    'clientId' => 'xxxxxxxxxxx.apps.googleusercontent.com',
    'clientSecret' => 'xxxxxxxxxxx',
    'refreshToken' => 'xxxxxxxxxxx',
    'folderId' => 'xxxxxxxxxxx',
    'sheetId' => 'xxxxxxxxxxx',
];

    'disks' => [
...
        'googleDrive' => [
            'driver' => 'googleDrive',
            'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
            'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
            'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
            'folderId' => env('GOOGLE_DRIVE_FOLDER_ID'),
            'sheetId' => env('GOOGLE_DRIVE_PATH_MANAGER_SHEET_ID'),
        ],
...
    ],

'providers' => [
    ...
    PrivateIT\FlySystem\GoogleDrive\GoogleDriveServiceProvider::class
    ...
]

$app->bind(\PrivateIT\FlySystem\GoogleDrive\PathManager::class, \PrivateIT\FlySystem\GoogleDrive\GoogleSheetsPathManager::class);

$disk = \Storage::disk('googleDrive');
$adapter = $disk->getDriver()->getAdapter();

$dir = 'test/sub1/sub2';
$fileName = 'test/sub1/sub2/new-file-1.txt';

var_dump($disk->makeDirectory($dir));
var_dump($disk->put($fileName, 'test content'));
var_dump($adapter->getUrl($fileName));
var_dump($disk->deleteDir($dir));
bash
php examples/test.php