PHP code example of funnydevjsc / google-drive-laravel-integrate

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

    

funnydevjsc / google-drive-laravel-integrate example snippets

bash
php artisan vendor:publish --provider="FunnyDev\GoogleDrive\GoogleDriveServiceProvider" --tag="funnydev-google-drive"
 php
use FunnyDev\GoogleDrive\GoogleDriveSdk;

class TestDrive
{
    /**
     * Handle the event.
     * @throws \Exception
     */
    public function handle(): void
    {
        $drive = new GoogleDriveSdk();
        
        $folderId = $drive->createFolder('test', config('google-drive.parent_folder_id'));
        
        $fileId = $drive->uploadFile(
            $folderId,
            'file_uploaded.txt',
            file_get_contents(storage_path('file.txt')),
            'text/plain'
        );
        
        $file = $drive->downloadFile($fileId);
        file_put_contents(storage_path('file_downloaded.txt'), $file);
        
        if ($drive->deleteResource($fileId)) {
            echo 'Deleted file';
        }
    }
}