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

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

mpsoft-digital/laravel-google-cloud-storage
===========================================

Google Cloud Storage filesystem driver for Laravel

2.2.3(2y ago)05MITPHPPHP ^8.0

Since Jul 23Pushed 2y agoCompare

[ Source](https://github.com/mpsoft-digital/laravel-google-cloud-storage)[ Packagist](https://packagist.org/packages/mpsoft-digital/laravel-google-cloud-storage)[ Docs](https://github.com/spatie/laravel-google-cloud-storage)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/mpsoft-digital-laravel-google-cloud-storage/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

Google Cloud Storage filesystem driver for Laravel
==================================================

[](#google-cloud-storage-filesystem-driver-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/13b3f6422e6627f5f64a16ac587cb60d9c1ac6dd6ad0b883c8641305c21ff1b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d676f6f676c652d636c6f75642d73746f726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-google-cloud-storage)[![run-tests](https://github.com/spatie/laravel-google-cloud-storage/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-google-cloud-storage/actions/workflows/run-tests.yml)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/34c29d27d749931b14d29d6a5776bc4a01d04d60d6f6a31317423c2daa92d450/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d676f6f676c652d636c6f75642d73746f726167652f436865636b253230262532306669782532307374796c696e672f6d61696e3f6c6162656c3d636f64652532307374796c65)](https://github.com/spatie/laravel-google-cloud-storage/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/8f2cf46c4edfc9b2275756f2ae85a941855eec7c5232df1620877de3111185e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d676f6f676c652d636c6f75642d73746f726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-google-cloud-storage)

---

Google Cloud Storage filesystem driver for Laravel 9 (using Flysystem v3 and its own GCS adapter).

**Looking for Laravel 8 support? Use the `v1` branch!**

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/6b99e3d44bb38884e24e7f16b38ea3b47422f297acdc2296d3624e2dc0a1e499/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d676f6f676c652d636c6f75642d73746f726167652e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-google-cloud-storage)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

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

Next, add a new disk to your `filesystems.php` config:

```
'gcs' => [
    'driver' => 'gcs',
    'key_file_path' => env('GOOGLE_CLOUD_KEY_FILE', null), // optional: /path/to/service-account.json
    'key_file' => [], // optional: Array of data that substitutes the .json file (see below)
    'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'), // optional: is included in key file
    'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET', 'your-bucket'),
    'path_prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', ''), // optional: /default/path/to/apply/in/bucket
    'storage_api_uri' => env('GOOGLE_CLOUD_STORAGE_API_URI', null), // see: Public URLs below
    'apiEndpoint' => env('GOOGLE_CLOUD_STORAGE_API_ENDPOINT', null), // set storageClient apiEndpoint
    'visibility' => 'public', // optional: public|private
    'visibility_handler' => null, // optional: set to \League\Flysystem\GoogleCloudStorage\UniformBucketLevelAccessVisibility::class to enable uniform bucket level access
    'metadata' => ['cacheControl'=> 'public,max-age=86400'], // optional: default metadata
],
```

Usage
-----

[](#usage)

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

$disk->put('avatars/1', $fileContents);
$exists = $disk->exists('file.jpg');
$time = $disk->lastModified('file1.jpg');
$disk->copy('old/file1.jpg', 'new/file1.jpg');
$disk->move('old/file1.jpg', 'new/file1.jpg');
$url = $disk->url('folder/my_file.txt');
$url = $disk->temporaryUrl('folder/my_file.txt', now()->addMinutes(30));
$disk->setVisibility('folder/my_file.txt', 'public');
```

See  for full list of available functionality.

### 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.

### Temporary / Signed URLs

[](#temporary--signed-urls)

With the latest adapter versions, you can easily generate a signed URLs for files that are not publicly visible by default.

```
$disk = Storage::disk('gcs');
$url = $disk->temporaryUrl('folder/my_file.txt', now()->addMinutes(30));
// https://storage.googleapis.com/test-bucket/folder/my_file.txt?GoogleAccessId=test-bucket%40test-gcp.iam.gserviceaccount.com&Expires=1571151576&Signature=tvxN1OS1txkWAUF0cCR3FWK%seRZXtFu42%04%YZACYL2zFQxA%uwdGEmdO1KgsHR3vBF%I9KaEzPbl4b7ic2IWUuo8Jh3IoZFqdTQec3KypjDtt%02DGwm%OO6pWDVV421Yp4z520%o5oMqGBtV8B3XmjW2PH76P3uID2QY%AlFxn23oE9PBoM2wXr8pDXhMPwZNJ0FtckSc26O8PmfVsG7Jvln%CQTU57IFyB7JnNxz5tQpc2hPTHbCGrcxVPEISvdOamW3I%83OsXr5raaYYBPcuumDnAmrK%cyS9%Ky2fL2B2shFO2cz%KRu79DBPqtnP2Zf1mJWBTwxVUCK2jxEEYcXBXtdOszIvlI6%tp2XfVwYxLNFU
```

Uniform bucket-level access
---------------------------

[](#uniform-bucket-level-access)

Google Cloud Storage allows setting permissions at the bucket level i.e. "Uniform bucket-level access".

Initially, the error "Cannot insert legacy ACL for an object when uniform bucket-level access is enabled" is observed.

When uploading files to such buckets ensure the `visibility_handler` within the configuration file is set as follows:

```
'visibility_handler' => \League\Flysystem\GoogleCloudStorage\UniformBucketLevelAccessVisibility::class,
```

Please see  and  for more info.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Superbalist](https://github.com/Superbalist) for the original GCS adapter package
- [Alex Vanderbist](https://github.com/alexvanderbist)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

1022d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d1aecd14e668000504d55a75055589dd8ef5eb5fa66b9973a8310eed531b7009?d=identicon)[mpsoft](/maintainers/mpsoft)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (26 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (24 commits)")[![mmachatschek](https://avatars.githubusercontent.com/u/10237069?v=4)](https://github.com/mmachatschek "mmachatschek (13 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (11 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (5 commits)")[![Rkallenkoot](https://avatars.githubusercontent.com/u/3198607?v=4)](https://github.com/Rkallenkoot "Rkallenkoot (2 commits)")[![veneliniliev](https://avatars.githubusercontent.com/u/5311085?v=4)](https://github.com/veneliniliev "veneliniliev (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![gcg](https://avatars.githubusercontent.com/u/811685?v=4)](https://github.com/gcg "gcg (1 commits)")[![MohannadNaj](https://avatars.githubusercontent.com/u/8743700?v=4)](https://github.com/MohannadNaj "MohannadNaj (1 commits)")[![hotrush](https://avatars.githubusercontent.com/u/1247004?v=4)](https://github.com/hotrush "hotrush (1 commits)")[![pedrotrek](https://avatars.githubusercontent.com/u/99328371?v=4)](https://github.com/pedrotrek "pedrotrek (1 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (1 commits)")[![rwinzhang](https://avatars.githubusercontent.com/u/1652090?v=4)](https://github.com/rwinzhang "rwinzhang (1 commits)")[![careybaird](https://avatars.githubusercontent.com/u/912566?v=4)](https://github.com/careybaird "careybaird (1 commits)")[![kaiompsoft](https://avatars.githubusercontent.com/u/85122219?v=4)](https://github.com/kaiompsoft "kaiompsoft (1 commits)")

---

Tags

spatielaravellaravel-google-cloud-storage

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-google-cloud-storage

Google Cloud Storage filesystem driver for Laravel

2408.9M13](/packages/spatie-laravel-google-cloud-storage)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M73](/packages/unisharp-laravel-filemanager)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[spatie/livewire-filepond

Upload files using Filepond in Livewire components

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

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)

PHPackages © 2026

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