PHPackages                             yaza/laravel-google-drive-storage - 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. yaza/laravel-google-drive-storage

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

yaza/laravel-google-drive-storage
=================================

This is my package laravel-google-drive-storage

V4.1.0(1y ago)200164.9k—2.3%44[5 PRs](https://github.com/yaza-putu/laravel-google-drive-storage/pulls)3MITPHPPHP ^8.2

Since Dec 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/yaza-putu/laravel-google-drive-storage)[ Packagist](https://packagist.org/packages/yaza/laravel-google-drive-storage)[ Docs](https://github.com/yaza-putu/laravel-google-drive-storage)[ RSS](/packages/yaza-laravel-google-drive-storage/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (14)Versions (15)Used By (3)

laravel-google-drive-storage
============================

[](#laravel-google-drive-storage)

[![gdrive](https://camo.githubusercontent.com/6fee949f62af80abaecf808a4d1e42c42655f5e8aefeba79b7831bb20ce6ca0f/68747470733a2f2f6973342d73736c2e6d7a7374617469632e636f6d2f696d6167652f7468756d622f507572706c653132322f76342f64392f63622f61382f64396362613862312d383561302d373233612d336630332d6264633662373634373664352f6c6f676f5f64726976655f3230323071345f636f6c6f722d302d31785f55303037656d61726b6574696e672d302d302d302d362d302d302d302d38352d3232302e706e672f313230307836333077612e706e67)](https://camo.githubusercontent.com/6fee949f62af80abaecf808a4d1e42c42655f5e8aefeba79b7831bb20ce6ca0f/68747470733a2f2f6973342d73736c2e6d7a7374617469632e636f6d2f696d6167652f7468756d622f507572706c653132322f76342f64392f63622f61382f64396362613862312d383561302d373233612d336630332d6264633662373634373664352f6c6f676f5f64726976655f3230323071345f636f6c6f722d302d31785f55303037656d61726b6574696e672d302d302d302d362d302d302d302d38352d3232302e706e672f313230307836333077612e706e67)This package allow to store and get data from google drive like S3 AWS in laravel

Support
-------

[](#support)

- laravel 12 (php 8.4) use V4.x
- Laravel 11 (php 8.2) use V3.x
- Laravel 10 (php 8.1) use V2.0.0

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

[](#installation)

You can install the package via composer:

```
composer require yaza/laravel-google-drive-storage
```

copy to .env

```
FILESYSTEM_CLOUD=google
GOOGLE_DRIVE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=xxx
GOOGLE_DRIVE_REFRESH_TOKEN=xxx
GOOGLE_DRIVE_ACCESS_TOKEN=xxx
GOOGLE_DRIVE_FOLDER=
```

config filesystem.php

```
'disks' => [
    'google' => [
      'driver' => 'google',
      'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
      'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
      'accessToken' => env('GOOGLE_DRIVE_ACCESS_TOKEN'), // optional
      'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
      'folder' => env('GOOGLE_DRIVE_FOLDER'),
    ]
]
```

Setup Google Keys
-----------------

[](#setup-google-keys)

- [Getting your Client ID and Secret](https://github.com/ivanvermeyen/laravel-google-drive-demo/blob/master/README/1-getting-your-dlient-id-and-secret.md)
- [Getting your Refresh Token](https://github.com/ivanvermeyen/laravel-google-drive-demo/blob/master/README/2-getting-your-refresh-token.md)

Usage
-----

[](#usage)

you can use storage driver function by laravel
example :

```
 Storage::disk('google')->put($filename, File::get($filepath));
```

refrensi code opration [sample code](https://github.com/ivanvermeyen/laravel-google-drive-demo/blob/master/routes/web.php)

Usage with `accessToken`. Could be useful if you want to use your user's token e.g upload a file in their own Drive.

```
// Build an on-demand disk
$disk = Storage::build([
    'driver' => 'google',
    'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
    'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
    'accessToken' => auth()->user()->google_access_token, // Get from authenticated user
    'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
    'folder' => env('GOOGLE_DRIVE_FOLDER'),
]);

$disk->put($filename, File::get($filepath));
```

or use helper from this package
- Put File

```
use Yaza\LaravelGoogleDriveStorage\Gdrive;

Gdrive::put('location/filename.png', $request->file('file'));
// or
Gdrive::put('filename.png', public_path('path/filename.png'));
```

- Get File

```
use Yaza\LaravelGoogleDriveStorage\Gdrive;

$data = Gdrive::get('path/filename.png');

return response($data->file, 200)
    ->header('Content-Type', $data->ext);
```

- Get Large File with stream

```
use Yaza\LaravelGoogleDriveStorage\Gdrive;

  $readStream = Gdrive::readStream('path/filename.png');

return response()->stream(function () use ($readStream) {
    fpassthru($readStream->file);
}, 200, [
    'Content-Type' => $readStream->ext,
    //'Content-disposition' => 'attachment; filename="'.$filename.'"', // force download?
]);
```

- download file

```
use Yaza\LaravelGoogleDriveStorage\Gdrive;

 $data = Gdrive::get('path/filename.png');
        return response($data->file, 200)
            ->header('Content-Type', $data->ext)
            ->header('Content-disposition', 'attachment; filename="'.$data->filename.'"');
```

- delete

```
use Yaza\LaravelGoogleDriveStorage\Gdrive;

 Gdrive::delete('path/filename.png');
```

- delete directory

```
use Yaza\LaravelGoogleDriveStorage\Gdrive;

  Gdrive::deleteDir('foldername');
```

- make directory

```
use Yaza\LaravelGoogleDriveStorage\Gdrive;

  Gdrive::makeDir('foldername');
```

- rename directory

```
use Yaza\LaravelGoogleDriveStorage\Gdrive;

  Gdrive::renameDir('oldfolderpath', 'newfolder');
```

- all folder &amp; file

```
use Yaza\LaravelGoogleDriveStorage\Gdrive;

Gdrive::all('/');
// or
Gdrive::all('foldername');
```

output

```
Illuminate\Support\Collection {#804 ▼ // app/Http/Controllers/UploadController.php:70
  #items: array:3 [▼
    0 => League\Flysystem\DirectoryAttributes {#798 ▶}
    1 => League\Flysystem\FileAttributes {#796 ▶}
    2 => League\Flysystem\DirectoryAttributes {#783 ▶}
  ]
  #escapeWhenCastingToString: false
}
```

- all folder &amp; file with sub folder

```
use Yaza\LaravelGoogleDriveStorage\Gdrive;

Gdrive::all('/', true);
// or
Gdrive::all('foldername', true);
```

output

```
Illuminate\Support\Collection {#804 ▼ // app/Http/Controllers/UploadController.php:70
  #items: array:3 [▼
    0 => League\Flysystem\DirectoryAttributes {#798 ▶}
    1 => League\Flysystem\FileAttributes {#796 ▶}
    2 => League\Flysystem\DirectoryAttributes {#783 ▶}
  ]
  #escapeWhenCastingToString: false
}
```

Limitations
-----------

[](#limitations)

Using display paths as identifiers for folders and files requires them to be unique. Unfortunately Google Drive allows users to create files and folders with same (displayed) names. In such cases when unique path cannot be determined this adapter chooses the oldest (first) instance. In case the newer duplicate is a folder and user puts a unique file or folder inside the adapter will be able to reach it properly (because full path is unique).

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [yaza](https://github.com/yaza-putu)
- [All Contributors](../../contributors)

Thanks to [Masbug](https://github.com/masbug/flysystem-google-drive-ext)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance45

Moderate activity, may be stable

Popularity53

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~93 days

Recently: every ~137 days

Total

10

Last Release

422d ago

Major Versions

V1.1.4 → V2.0.02023-09-20

V2.0.0 → V3.0.02024-05-11

V3.0.0 → V4.0.02025-03-12

PHP version history (3 changes)V1.0.0PHP ^8.1

V3.0.0PHP ^8.2

V4.0.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/37f00f8a1d0ca01c4232359f171fe2d47269b94cbb1f1040e7b6cf341938a14c?d=identicon)[yaza](/maintainers/yaza)

---

Top Contributors

[![yaza-putu](https://avatars.githubusercontent.com/u/59905886?v=4)](https://github.com/yaza-putu "yaza-putu (60 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![SPQRBrutus](https://avatars.githubusercontent.com/u/6303506?v=4)](https://github.com/SPQRBrutus "SPQRBrutus (1 commits)")[![yasa32putu](https://avatars.githubusercontent.com/u/169970895?v=4)](https://github.com/yasa32putu "yasa32putu (1 commits)")[![shoaibsharif](https://avatars.githubusercontent.com/u/29075110?v=4)](https://github.com/shoaibsharif "shoaibsharif (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![acgonzales](https://avatars.githubusercontent.com/u/44025870?v=4)](https://github.com/acgonzales "acgonzales (1 commits)")

---

Tags

laravel-google-drivelaravel-google-drive-storagelaravel-storagelaravel-google-drive-storage

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/yaza-laravel-google-drive-storage/health.svg)

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

###  Alternatives

[spatie/livewire-filepond

Upload files using Filepond in Livewire components

306452.7k3](/packages/spatie-livewire-filepond)[elegantly/laravel-invoices

Store invoices safely in your Laravel application

23131.8k](/packages/elegantly-laravel-invoices)[shuvroroy/filament-spatie-laravel-backup

This plugin is built on top of Spatie's Laravel-backup package

268356.4k6](/packages/shuvroroy-filament-spatie-laravel-backup)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[djurovicigoor/lara-files

Lara-files is a package which will make it easier to work with files. Package has built-in support for DigitalOcean spaces and Amazon S3.

1196.5k](/packages/djurovicigoor-lara-files)[mwguerra/filemanager

A full-featured file manager package for Laravel and Filament v5 with dual operating modes, drag-and-drop uploads, S3/MinIO support, and comprehensive security features.

718.5k1](/packages/mwguerra-filemanager)

PHPackages © 2026

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