PHP code example of vatri / google-drive-bundle

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

    

vatri / google-drive-bundle example snippets


// config/bundles.php

return [
    // ...
    App\Vatri\GoogleDriveBundle\VatriGoogleDriveBundle::class => ['dev' => true, 'test' => true],
];

 use Vatri\GoogleDriveBundle\Service\DriveApiService;
 ...

 public function test(DriveApiService $driveApiService): Response
 {
   if($driveApiService->isTokenExpired()){
      return $this->redirectToRoute( $driveApiService->getAuthRouteName() );
   }
   $folderId = '[YOUR ID]';
   $res = $driveApiService->listFiles($folderId, false, true );
   dd($res);
 }

if($driveApiService->isTokenExpired()){
   
   // When auth is finished, redirect back to this URL:
   $driveApiService->setRedirectPathAfterAuth(
      $this->get('request_stack')->getCurrentRequest()->getRequestUri()
   );
   
   // Redirect
   return $this->redirectToRoute( $driveApiService->getAuthRouteName() );
}