PHP code example of basecardhero / drive

1. Go to this page and download the library: Download basecardhero/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/ */

    

basecardhero / drive example snippets

 php
lient = new \Google_Client(); // Make sure to configure your Google client.
$driveService = new \Google_Service_Drive($client);
$drive = new \BaseCardHero\Drive\Drive($driveService);
 php
$drive->getService() // \Google_Service_Drive
 php
$file = $drive->get('efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV');

echo get_class($file); // \Google_Service_Drive_DriveFile
echo $file->id; // 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV'
 php
$fileId = 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV';
$permissions = $drive->setPermission($fileId, 'anyone', 'reader');

echo get_class($permissions); // \Google_Service_Drive_Permission
 php
$file = $drive->create('My File', 'application/vnd.google-apps.file');

echo get_class($file); // \Google_Service_Drive_DriveFile
echo $file->id; // 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV'
 php
$folder = $drive->createFolder('My Folder');

echo get_class($folder); // \Google_Service_Drive_DriveFile
echo $folder->id; // 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV'
 php
$fileId = 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV';

$drive->delete($fileId); // null