PHPackages                             jervi-sir/flysystem-gdrive-api - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. jervi-sir/flysystem-gdrive-api

ActiveLibrary[File &amp; Storage](/categories/file-storage)

jervi-sir/flysystem-gdrive-api
==============================

Flysystem adapter for Google Drive

121PHP

Since Jul 7Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Jervi-sir/flysystem-google-drive)[ Packagist](https://packagist.org/packages/jervi-sir/flysystem-gdrive-api)[ RSS](/packages/jervi-sir-flysystem-gdrive-api/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

 Note
======

[](#-note-)

 This Project is from [ nao-pon/ ](https://github.com/nao-pon)I cloned it here to apply some changes for an urgent project, due to the impossibility to edit vendor files directly

so all efforts go to nao-pon/

 [check the original repo here](https://github.com/nao-pon/flysystem-google-drive)

\# Flysystem Adapter for Google Drive [![Author](https://camo.githubusercontent.com/204e32c8ec40a28cd778a206d8f90cb3bf783a9c40c1872bf5f97ff06df7b90e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d6e616f2d2d706f6e2532306879707765622d626c75652e7376673f7374796c653d666c6174)](http://xoops.hypweb.net/)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Installation
------------

[](#installation)

Steps won't be the same as the original repo.

```
composer require spatie/laravel-backup 7.3.3
```

```
php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"
```

- Then in config/backup.php add the following:

```
'disks' => [
    'google',
    'local',
],

```

```
composer require jervi-sir/flysystem-gdrive-api:~1.1
```

```
php artisan make:provider GoogleDriveServiceProvider
```

- In app/Providers/GoogleDriveServiceProvider.php, also declare it in config/app.php file.

```
public function boot()
{
    \Storage::extend('google', function ($app, $config) {
        $client = new \Google_Client();
        $client->setClientId($config['clientId']);
        $client->setClientSecret($config['clientSecret']);
        $client->refreshToken($config['refreshToken']);
        $service = new \Google_Service_Drive($client);
        $adapter = new \Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter($service, $config['folderId']);

        return new \League\Flysystem\Filesystem($adapter);
    });
}

```

- Declare google provider in config/app.php

```
App\Providers\GoogleDriveServiceProvider::class,

```

- In config/filesystem.php

```
return [

    // ...

    'disks' => [

        // ...

        'google' => [
            'driver' => 'google',
            'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
            'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
            'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
            'folderId' => env('GOOGLE_DRIVE_FOLDER_ID'),
        ],

        // ...

    ],

    // ...
];

```

- In .env

```
GOOGLE_DRIVE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=xxx
GOOGLE_DRIVE_REFRESH_TOKEN=xxx
GOOGLE_DRIVE_FOLDER_ID=null

```

Get Google credentials
----------------------

[](#get-google-credentials)

[Check this article](https://qirolab.com/posts/how-to-setup-laravel-backup-on-google-drive-1607368130) of How To Setup Laravel Backup On Google Drive?

Then execute following bash

```
php artisan backup:run

```

Usage
-----

[](#usage)

- In a controller

```
//Create a disk
$disk = Storage::disk('google');
//Create Image Object (Image Intervention package must be installed)
$img = Image::make($image)->orientate()->encode('jpg', 50);
$img->encode();
//Upload file
$disk->put($file_name, $img->getEncoded());
//get the Id
$pic_id = $disk->getDriver()->getAdapter()->getCacheFileObjectsByName()->id;

```

Remark
------

[](#remark)

Notice that in previous code I called the function getCacheFileObjectsByName(), this is the only change I needed for this package, to get access to the private variable CacheFileObjectsByName, so I can get uploaded file's id

- here is the change In GoogleDriveAdapter.php, I added

```
public function getCacheFileObjectsByName()
{
    return array_values($this->cacheFileObjectsByName)[0];
}

```

Credit
------

[](#credit)

- [How to setup Laravel backup on google drive](https://qirolab.com/posts/how-to-setup-laravel-backup-on-google-drive-1607368130)
- [Flysystem Adapter for Google Drive](https://github.com/nao-pon/flysystem-google-drive)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/54365256?v=4)[Jervi Sir](/maintainers/Jervi-sir)[@Jervi-sir](https://github.com/Jervi-sir)

---

Top Contributors

[![Jervi-sir](https://avatars.githubusercontent.com/u/54365256?v=4)](https://github.com/Jervi-sir "Jervi-sir (7 commits)")

### Embed Badge

![Health badge](/badges/jervi-sir-flysystem-gdrive-api/health.svg)

```
[![Health](https://phpackages.com/badges/jervi-sir-flysystem-gdrive-api/health.svg)](https://phpackages.com/packages/jervi-sir-flysystem-gdrive-api)
```

###  Alternatives

[venveo/craft-compress

Create smart zip files from Craft assets on the fly

124.7k](/packages/venveo-craft-compress)

PHPackages © 2026

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