PHPackages                             sinapsteknologi/laravel-gdrive-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. sinapsteknologi/laravel-gdrive-storage

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

sinapsteknologi/laravel-gdrive-storage
======================================

Laravel filesystem disk for Google Drive (Shared Drive &amp; Service Account support)

1.0.1(3mo ago)011MITPHPPHP ^8.1

Since Jan 12Pushed 3mo agoCompare

[ Source](https://github.com/sinapsteknologi/laravel-gdrive-storage)[ Packagist](https://packagist.org/packages/sinapsteknologi/laravel-gdrive-storage)[ RSS](/packages/sinapsteknologi-laravel-gdrive-storage/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (6)Used By (0)

Laravel Google Drive Storage
============================

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

A Laravel filesystem disk implementation for Google Drive using **Google Service Accounts**. Designed for backend storage, media distribution, and controlled file access.

---

Why use this package
--------------------

[](#why-use-this-package)

Unlike Flysystem adapters, this package is designed for Laravel-first usage with signed temporary URLs, Shared Drive support, and minimal refactoring from existing Storage-based code.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 10
- Google Drive API enabled

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

[](#installation)

### 1. Create Google Service Account &amp; Download Credentials

[](#1-create-google-service-account--download-credentials)

This package uses **Google Service Account authentication**, not OAuth user login.

#### a. Open Google Cloud Console

[](#a-open-google-cloud-console)

-
- Select or create a **Project**

#### b. Enable Google Drive API

[](#b-enable-google-drive-api)

- Navigate to **APIs &amp; Services → Library**
- Search for **Google Drive API**
- Click **Enable**

#### c. Create Service Account

[](#c-create-service-account)

- Go to **APIs &amp; Services → Credentials**
- Click **Create Credentials → Service Account**
- Fill in:

    - Service account name (e.g. `laravel-gdrive-storage`)
- Click **Done**

#### d. Generate JSON Key

[](#d-generate-json-key)

- Open the created service account
- Go to **Keys** tab
- Click **Add Key → Create new key**
- Select **JSON**
- A file will be downloaded:

```
service-account.json

```

### Security Notes

[](#security-notes)

- Never commit `service-account.json` to version control
- Store credentials outside the public directory
- Rotate service account keys periodically

---

### 2. Share Target Google Drive Folder

[](#2-share-target-google-drive-folder)

This package **does not operate on the root Drive**. You must use a **specific folder**. This folder may exist in **My Drive or a Shared Drive**.

1. Open Google Drive
2. Create a folder (example: `Laravel Storage`)
3. Right-click → **Share**
4. Add the service account email (format: `xxxx@xxxx.iam.gserviceaccount.com`)
5. Permission: **Editor**
6. Copy the **Folder ID**

Example URL:

```
https://drive.google.com/drive/u/2/folders/1AbCDefGhIJkLmNop
                                            ↑
                                        folder_id

```

---

### 3. Install Package via Composer

[](#3-install-package-via-composer)

```
composer require sinapsteknologi/laravel-gdrive-storage
```

---

### 4. Publish Configuration

[](#4-publish-configuration)

```
php artisan vendor:publish --tag=gdrive-storage-config
```

This will create:

```
config/gdrive-storage.php
```

---

### 5. Configure Environment Variables

[](#5-configure-environment-variables)

By default, the package looks for the service account file at:

`storage/app/google/service-account.json`

If you want to use a different location, specify the path in your `.env` file.

Example:

Place the `service-account.json` file in `storage/service-account.json`, then add the path information to your `.env` file.

```
GDRIVE_SERVICE_ACCOUNT_PATH=storage/service-account.json
```

Then add the `folder_id` information to your `.env` file:

```
GOOGLE_DRIVE_SHARED_FOLDER_ID=1AbCDefGhIJkLmNop
```

---

### 6. Configure Filesystem Disk

[](#6-configure-filesystem-disk)

Add the disk configuration to `config/filesystems.php`:

```
'disks' => [

    'gdrive' => [
        'driver' => 'gdrive',
    ],

],
```

---

### 7. Basic Usage

[](#7-basic-usage)

```
use Illuminate\Support\Facades\Storage;

Storage::disk('gdrive')->put('hello.txt', 'Hello Google Drive');

Storage::disk('gdrive')->files();

Storage::disk('gdrive')->exists('hello.txt');
```

---

### 8. Temporary Download URL

[](#8-temporary-download-url)

```
$url = Storage::disk('gdrive')->temporaryUrl(
    'hello.txt',
    now()->addMinutes(5)
);
```

The generated URL is signed and expires automatically. The URL points to a signed Laravel route and will return a streamed response from Google Drive when accessed.

---

Available Filesystem Methods
----------------------------

[](#available-filesystem-methods)

The `gdrive` disk is designed to be **API-compatible with Laravel's filesystem**, so it can be used as a drop-in replacement for other cloud disks (such as S3 or Dropbox) with minimal or no code changes.

MethodDescription`exists($path)`Check whether a file or directory exists`put($path, $contents)`Create or overwrite a file`putFileAs($directory, $file, $name)`Upload a file with a specific name`get($path)`Get file contents`size($path)`Get file size in bytes`files($directory = '')`List files in a directory`directories($directory = '')`List subdirectories`delete($path)`Delete a file`copy($from, $to)`Copy a file`move($from, $to)`Move or rename a file`makeDirectory($path)`Create directories recursively`deleteDirectory($path)`Delete a directory recursively`lastModified($path)`Get last modified timestamp`mimeType($path)`Get MIME type`url($path)`Get Google Drive viewer URL`download($path, $name = null)`Stream file as HTTP download`readStream($path)`Get PHP stream resource`temporaryUrl($path, $expiration, $options = [])`Generate signed temporary download URL### Notes

[](#notes)

- All paths are **relative to the configured root folder ID**
- Fully supports **Shared Drives**

> If the folder is located inside a **Shared Drive**, make sure the service account is added as a **member of the Shared Drive**, not only to the folder itself.

- Directory deletion is **recursive**
- `temporaryUrl()` does **not** require public file sharing; it uses Laravel signed routes

---

Important Notes
---------------

[](#important-notes)

- ✅ Uses **Google Drive API directly**
- ✅ Service Account based (no user OAuth)
- ✅ Suitable for:

    - Media storage
    - Backup
    - Controlled file distribution
- ❌ Not suitable for:

    - Realtime filesystem mounting
    - Extremely high write frequency workloads

---

License
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance81

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~5 days

Total

5

Last Release

100d ago

Major Versions

0.1.2 → 1.0.02026-01-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f2e224c5017cf0610f6ad8a36d09d5d22a21caa524c62ed43fa13186a378691?d=identicon)[wellyrm](/maintainers/wellyrm)

---

Top Contributors

[![wellyrm](https://avatars.githubusercontent.com/u/7680277?v=4)](https://github.com/wellyrm "wellyrm (1 commits)")

### Embed Badge

![Health badge](/badges/sinapsteknologi-laravel-gdrive-storage/health.svg)

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

###  Alternatives

[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k35.6M75](/packages/aws-aws-sdk-php-laravel)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[stechstudio/laravel-zipstream

A fast and simple streaming zip file downloader for Laravel.

4633.7M3](/packages/stechstudio-laravel-zipstream)[spatie/laravel-google-cloud-storage

Google Cloud Storage filesystem driver for Laravel

2408.9M13](/packages/spatie-laravel-google-cloud-storage)[azure-oss/storage-blob-laravel

Azure Storage Blob filesystem driver for Laravel

63582.2k1](/packages/azure-oss-storage-blob-laravel)[spatie/laravel-backup-server

Backup multiple applications

17016.7k1](/packages/spatie-laravel-backup-server)

PHPackages © 2026

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