PHPackages                             vatri/google-drive-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. vatri/google-drive-bundle

ActiveSymfony-bundle[API Development](/categories/api)

vatri/google-drive-bundle
=========================

Google Drive API Bundle

v2.0.0(1y ago)86.8k5[5 issues](https://github.com/vatri/Google-Drive-Bundle/issues)[3 PRs](https://github.com/vatri/Google-Drive-Bundle/pulls)1MITPHP

Since Jun 18Pushed 1y ago2 watchersCompare

[ Source](https://github.com/vatri/Google-Drive-Bundle)[ Packagist](https://packagist.org/packages/vatri/google-drive-bundle)[ RSS](/packages/vatri-google-drive-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (3)Versions (19)Used By (1)

Google-Drive-Bundle
===================

[](#google-drive-bundle)

Google Drive API Bundle for Symfony 6 and 7.

Features
========

[](#features)

- Authorize via Google API
- Manage Google Drive files and folders
    - Create a folder (recursively)
    - Check if a folder exists
    - Find a file by ID
    - Delete a file
    - Download file
    - List files
    - Copy a file to specific directory
    - Upload a file
    - Add "starred" flag to a file/folder
    - Rename resource (file or folder)

Installation
============

[](#installation)

Applications that use Symfony Flex
----------------------------------

[](#applications-that-use-symfony-flex)

Open a command console, enter your project directory and execute:

```
$ composer require vatri/google-drive-bundle
```

Applications that don't use Symfony Flex
----------------------------------------

[](#applications-that-dont-use-symfony-flex)

### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require vatri/google-drive-bundle
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

### Step 2: Enable the Bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
// config/bundles.php

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

Usage
=====

[](#usage)

### 1. Add/edit following variables in your *.env* file:

[](#1-addedit-following-variables-in-your-env-file)

```
VATRI_GOOGLE_DRIVE_CREDENTIALS_FILE=config/YOUR_FILENAME.json`
VATRI_GOOGLE_DRIVE_REDIRECT_AFTER_AUTH=/

```

**Don't forget to replace default values with yours.**

### 2. Create (or check if exists) */config/routes/vatri\_google\_drive.yaml* file with following contents:

[](#2-create-or-check-if-exists-configroutesvatri_google_driveyaml-file-with-following-contents)

```
vatri_google_drive:
    resource: '@VatriGoogleDriveBundle/Controller/'
    type:     annotation
```

### 3. Download and configure JSON credentials file

[](#3-download-and-configure-json-credentials-file)

Download your JSON credentials file from Google Console to */config* folder within Symfony project.

Edit following variables in *.env* file:

`VATRI_GOOGLE_DRIVE_CREDENTIALS_FILE=config/google-drive-api-client_secrets.json-example.json``VATRI_GOOGLE_DRIVE_REDIRECT_AFTER_AUTH=/path/to/your/route`

### 4. Check and use AuthController

[](#4-check-and-use-authcontroller)

AuthController is default controller required for authorization of users via Google API. By default it saves an access token to cookie.

Also note that if you use this controller for authorization, you will add below route as callback URL in Google Console Credentials configuration.

1. Run

`php bin/console debug:router`

and check if you have a route like this:

```
vatri_google_drive_auth       ANY      ANY      ANY    /vatri_google_drive/auth

```

2. Now in order to authenticate users, you need to add link to the route like this:

```

    Login

```

### 5. Use DriveApiService in your controller or another Symfony part like this:

[](#5-use-driveapiservice-in-your-controller-or-another-symfony-part-like-this)

```
 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);
 }
```

### 6. Check if Drive API access token is expired and authorize if required:

[](#6-check-if-drive-api-access-token-is-expired-and-authorize-if-required)

Add the following code to your controller or other part:

```
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() );
}
```

Roadmap
=======

[](#roadmap)

### Version 1.2

[](#version-12)

- Symfony Flex recipe
- Logout controller
- Configure token storage (including custom one)

### Version 1.1

[](#version-11)

- renameFolder() method

### Version 1.0

[](#version-10)

- Automatically refresh access\_token using refresh\_token
- Uniformed responses from *DriveApiService* (a class)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance23

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 73% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~137 days

Recently: every ~237 days

Total

15

Last Release

597d ago

Major Versions

v1.4.2 → v2.0.02024-09-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/5eb5287e3a6dfb62917b806f3ba64456c2bda00bcb85e9b8b9fc57f7c8ade07e?d=identicon)[vatri](/maintainers/vatri)

---

Top Contributors

[![vatri](https://avatars.githubusercontent.com/u/1230120?v=4)](https://github.com/vatri "vatri (65 commits)")[![rezaf-dev](https://avatars.githubusercontent.com/u/90597273?v=4)](https://github.com/rezaf-dev "rezaf-dev (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![sd-milani](https://avatars.githubusercontent.com/u/57007587?v=4)](https://github.com/sd-milani "sd-milani (5 commits)")[![MaximeLemolt](https://avatars.githubusercontent.com/u/57484207?v=4)](https://github.com/MaximeLemolt "MaximeLemolt (3 commits)")[![artyuum](https://avatars.githubusercontent.com/u/17199757?v=4)](https://github.com/artyuum "artyuum (1 commits)")

---

Tags

composer-packagegoogle-drive-apiphpsymfonysymfony-bundle

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vatri-google-drive-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/vatri-google-drive-bundle/health.svg)](https://phpackages.com/packages/vatri-google-drive-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[cravler/maxmind-geoip-bundle

Bundle integrating MaxMind GeoIP2 database into symfony application

27615.8k2](/packages/cravler-maxmind-geoip-bundle)[happyr/google-api-bundle

A Symfony2 Wrapper for the Google APIs Client Library for PHP

48196.1k](/packages/happyr-google-api-bundle)[sulu/headless-bundle

Bundle that provides controllers and services for using Sulu as headless content management system

55133.7k2](/packages/sulu-headless-bundle)[mediafigaro/google-analytics-api-symfony

Google Analytics API v4 Symfony

46177.7k](/packages/mediafigaro-google-analytics-api-symfony)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
