PHPackages                             devmagellan/laravel-google-cloud-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. devmagellan/laravel-google-cloud-storage

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

devmagellan/laravel-google-cloud-storage
========================================

A Google Cloud Storage filesystem for Laravel

00PHP

Since Aug 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/imediasun/laravel-google-cloud-storage)[ Packagist](https://packagist.org/packages/devmagellan/laravel-google-cloud-storage)[ RSS](/packages/devmagellan-laravel-google-cloud-storage/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-google-cloud-storage
============================

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

A Google Cloud Storage filesystem for Laravel.

[![Author](https://camo.githubusercontent.com/e482ac7a627cff7d6338f107ae19eacafe09713e09078d66ed26a7963c095cf4/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d404465766d6167656c6c616e2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/Devmagellan)[![Build Status](https://camo.githubusercontent.com/03d7ba4ea45b67400291ab1d1b5a561d06e0892afb6b4c6bfaed558f269dea8d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4465766d6167656c6c616e2f6c61726176656c2d676f6f676c652d636c6f75642d73746f726167652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Devmagellan/laravel-google-cloud-storage)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/c5049045cae393c60faea3c817f07035cfd0262b3070b61f4792e3e98c56c5f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f4465766d6167656c6c616e2f6c61726176656c2d676f6f676c652d636c6f75642d73746f726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Devmagellan/laravel-google-cloud-storage)[![Total Downloads](https://camo.githubusercontent.com/8d4993b8947cc36a6fc06ea6c9fff815d3c0a205b6816a76255bd865f996bee9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4465766d6167656c6c616e2f6c61726176656c2d676f6f676c652d636c6f75642d73746f726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Devmagellan/laravel-google-cloud-storage)

This package is a wrapper bridging [flysystem-google-storage](https://github.com/Devmagellan/flysystem-google-storage) into Laravel as an available storage disk.

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

[](#installation)

```
composer require Devmagellan/laravel-google-cloud-storage
```

If you are on Laravel 5.4 or earlier, then register the service provider in app.php

```
'providers' => [
    // ...
    Devmagellan\LaravelGoogleCloudStorage\GoogleCloudStorageServiceProvider::class,
]
```

If you are on Laravel 5.5 or higher, composer will have registered the provider automatically for you.

Add a new disk to your `filesystems.php` config

```
'gcs' => [
    'driver' => 'gcs',
    'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'),
    'key_file' => env('GOOGLE_CLOUD_KEY_FILE', null), // optional: /path/to/service-account.json
    'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET', 'your-bucket'),
    'path_prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', null), // optional: /default/path/to/apply/in/bucket
    'storage_api_uri' => env('GOOGLE_CLOUD_STORAGE_API_URI', null), // see: Public URLs below
    'visibility' => 'public', // optional: public|private
],
```

### Authentication

[](#authentication)

The Google Client uses a few methods to determine how it should authenticate with the Google API.

1. If you specify a path in the key `key_file` in disk config, that json credentials file will be used.
2. If the `GOOGLE_APPLICATION_CREDENTIALS` env var is set, it will use that.

    ```
    putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');
    ```
3. It will then try load the key file from a 'well known path':

    - windows: %APPDATA%/gcloud/application\_default\_credentials.json
    - others: $HOME/.config/gcloud/application\_default\_credentials.json
4. If running in **Google App Engine**, the built-in service account associated with the application will be used.
5. If running in **Google Compute Engine**, the built-in service account associated with the virtual machine instance will be used.
6. If you want to authenticate directly without using a json file, you can specify an array for `key_file` in disk config with this data:

    ```
    'key_file' => [
        'type' => env('GOOGLE_CLOUD_ACCOUNT_TYPE'),
        'private_key_id' => env('GOOGLE_CLOUD_PRIVATE_KEY_ID'),
        'private_key' => env('GOOGLE_CLOUD_PRIVATE_KEY'),
        'client_email' => env('GOOGLE_CLOUD_CLIENT_EMAIL'),
        'client_id' => env('GOOGLE_CLOUD_CLIENT_ID'),
        'auth_uri' => env('GOOGLE_CLOUD_AUTH_URI'),
        'token_uri' => env('GOOGLE_CLOUD_TOKEN_URI'),
        'auth_provider_x509_cert_url' => env('GOOGLE_CLOUD_AUTH_PROVIDER_CERT_URL'),
        'client_x509_cert_url' => env('GOOGLE_CLOUD_CLIENT_CERT_URL'),
    ],
    ```

### Public URLs

[](#public-urls)

The adapter implements a `getUrl($path)` method which returns a public url to a file.

> **Note:** Method available for Laravel 5.2 and higher. If used on 5.1, it will throw an exception.

```
$disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://storage.googleapis.com/bucket-name/folder/my_file.txt
```

If you configure a `path_prefix` in your config:

```
$disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://storage.googleapis.com/bucket-name/path-prefix/folder/my_file.txt
```

If you configure a custom `storage_api_uri` in your config:

```
$disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://your-custom-domain.com/bucket-name/path-prefix/folder/my_file.txt
```

For a custom domain (storage api uri), you will need to configure a CNAME DNS entry pointing to `storage.googleapis.com`.

Please see  for further instructions.

Usage
-----

[](#usage)

```
$disk = Storage::disk('gcs');

// create a file
$disk->put('avatars/1', $fileContents);

// check if a file exists
$exists = $disk->exists('file.jpg');

// get file modification date
$time = $disk->lastModified('file1.jpg');

// copy a file
$disk->copy('old/file1.jpg', 'new/file1.jpg');

// move a file
$disk->move('old/file1.jpg', 'new/file1.jpg');

// get url to file
$url = $disk->url('folder/my_file.txt');

// Set the visibility of file to public
$disk->setVisibility('folder/my_file.txt', 'public');

// See https://laravel.com/docs/5.3/filesystem for full list of available functionality
```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

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://www.gravatar.com/avatar/aafb873dc370255479b4d88803458d1c4fc8e4c36cefe659d82eaa857340ce6b?d=identicon)[devmagellan](/maintainers/devmagellan)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M123](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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