PHPackages                             spatie/flysystem-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. spatie/flysystem-google-cloud-storage

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

spatie/flysystem-google-cloud-storage
=====================================

Flysystem adapter for Google Cloud Storage

1.1.2(3y ago)24647.8k↑10.7%2MITPHPPHP ^8.0CI passing

Since Jul 27Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/spatie/flysystem-google-cloud-storage)[ Packagist](https://packagist.org/packages/spatie/flysystem-google-cloud-storage)[ Docs](https://github.com/spatie/flysystem-google-cloud-storage)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-flysystem-google-cloud-storage/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (7)Dependencies (7)Versions (8)Used By (0)

Flysystem adapter for Google Cloud Storage
==========================================

[](#flysystem-adapter-for-google-cloud-storage)

[![Latest Version on Packagist](https://camo.githubusercontent.com/526cb6dc2bd5b878c4ef76c1df9d1e6d6aecb7f9bba2c64f8dbd76fad68f6e20/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f666c7973797374656d2d676f6f676c652d636c6f75642d73746f726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/flysystem-google-cloud-storage)[![GitHub Tests Action Status](https://github.com/spatie/flysystem-google-cloud-storage/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/flysystem-google-cloud-storage/actions?query=workflow%3ATests+branch%3Amain)[![GitHub Code Style Action Status](https://github.com/spatie/flysystem-google-cloud-storage/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/spatie/flysystem-google-cloud-storage/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/37fb5df1ac06792b32dbc8bde752128204b302d64ac1d3fe4f9713d1c39927f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f666c7973797374656d2d676f6f676c652d636c6f75642d73746f726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/flysystem-google-cloud-storage)

This package contains a [Google Cloud Storage](https://cloud.google.com/storage) driver for [Flysystem v1](https://flysystem.thephpleague.com).

(If you need Google Cloud Storage support on Flysystem v2 or above (or Laravel 9), this package is not for you)

### Notice

[](#notice)

This package is a fork from [superbalist/flysystem-google-cloud-storage](https://github.com/Superbalist/flysystem-google-cloud-storage). Changes include:

- PHP 8 only
- merged random open PRs from Superbalist's package

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

[](#support-us)

[![](https://camo.githubusercontent.com/fbdcc6fae6bf702e83677bf49057f8be90b883a6c8a730e3c4dcda18b60565c1/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f666c7973797374656d2d676f6f676c652d636c6f75642d73746f726167652e6a70673f743d31)](https://spatie.be/github-ad-click/flysystem-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/flysystem-google-cloud-storage
```

Authentication
--------------

[](#authentication)

Before you can use the package, you'll need to authenticate with Google. When possible, the credentials will be auto-loaded by the Google Cloud Client.

1. The client will first look at the GOOGLE\_APPLICATION\_CREDENTIALS env var. You can use `putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');` to set the location of your credentials file.
2. The client will look for the credentials file at the following paths:
    - Windows: `%APPDATA%/gcloud/application_default_credentials.json`
    - MacOS/Unix: `$HOME/.config/gcloud/application_default_credentials.json`
3. If running in Google App Engine, Google Compute Engine or GKE, the built-in service account associated with the app, instance or cluster will be used.

Using this in a Kubernetes cluster? Take a look at [Workload Identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity).

Usage
-----

[](#usage)

Here's an example that shows you have you can call the various functions to manipulate files on Google Cloud.

```
use Google\Cloud\Storage\StorageClient;
use League\Flysystem\Filesystem;
use Spatie\GoogleCloudStorageAdapter\GoogleCloudStorageAdapter;

$storageClient = new StorageClient([
    'projectId' => 'your-project-id',
    // The credentials can manually be specified by passing in a keyFilePath.
    // 'keyFilePath' => '/path/to/service-account.json',
]);

$bucket = $storageClient->bucket('your-bucket-name');

$adapter = new GoogleCloudStorageAdapter($storageClient, $bucket);

$filesystem = new Filesystem($adapter);

$filesystem->write('path/to/file.txt', 'contents');
$filesystem->update('path/to/file.txt', 'new contents');
$contents = $filesystem->read('path/to/file.txt');
$exists = $filesystem->has('path/to/file.txt');
$filesystem->delete('path/to/file.txt');
$filesystem->rename('filename.txt', 'newname.txt');
$filesystem->copy('filename.txt', 'duplicate.txt');
$filesystem->deleteDir('path/to/directory');
```

See  for full list of available functionality

### Using a custom storage URI

[](#using-a-custom-storage-uri)

You can configure this adapter to use a custom storage URI. Read more about configuring a custom domain for Google Cloud Storage [here](https://cloud.google.com/storage/docs/request-endpoints#cname).

When using a custom storage URI, the bucket name will not prepended to the file path:

```
use Google\Cloud\Storage\StorageClient;
use League\Flysystem\Filesystem;
use Spatie\GoogleCloudStorageAdapter\GoogleCloudStorageAdapter;

$storageClient = new StorageClient([
    'projectId' => 'your-project-id',
]);
$bucket = $storageClient->bucket('your-bucket-name');
$adapter = new GoogleCloudStorageAdapter($storageClient, $bucket);

// URI defaults to "https://storage.googleapis.com":
$filesystem = new Filesystem($adapter);
$filesystem->getUrl('path/to/file.txt');
// "https://storage.googleapis.com/your-bucket-name/path/to/file.txt"

// Using custom storage uri:
$adapter->setStorageApiUri('http://example.com');
$filesystem = new Filesystem($adapter);
$filesystem->getUrl('path/to/file.txt');
// "http://example.com/path/to/file.txt"

// You can also prefix the file path if needed:
$adapter->setStorageApiUri('http://example.com');
$adapter->setPathPrefix('extra-folder/another-folder/');
$filesystem = new Filesystem($adapter);
$filesystem->getUrl('path/to/file.txt');
// "http://example.com/extra-folder/another-folder/path/to/file.txt"
```

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)

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

License
-------

[](#license)

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

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance56

Moderate activity, may be stable

Popularity47

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 64.9% 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 ~120 days

Recently: every ~180 days

Total

7

Last Release

1125d ago

Major Versions

0.0.3 → 1.0.02022-02-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (24 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (7 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (5 commits)")[![alexandrmazur96](https://avatars.githubusercontent.com/u/20535375?v=4)](https://github.com/alexandrmazur96 "alexandrmazur96 (1 commits)")

---

Tags

flysystemgoogle-cloudphpspatieflysystem-google-cloud-storage

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.9k556.2M21.5k](/packages/laravel-framework)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k293.8M1.2k](/packages/league-flysystem-aws-s3-v3)[spatie/laravel-backup

A Laravel package to backup your application

6.0k25.4M272](/packages/spatie-laravel-backup)[unisharp/laravel-filemanager

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

2.2k3.6M90](/packages/unisharp-laravel-filemanager)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k21](/packages/tempest-framework)[spatie/flysystem-dropbox

Flysystem Adapter for the Dropbox v2 API

3655.1M89](/packages/spatie-flysystem-dropbox)

PHPackages © 2026

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