{"id":19325013,"url":"https://github.com/spatie/flysystem-google-cloud-storage","last_synced_at":"2025-04-22T20:31:09.260Z","repository":{"id":41810974,"uuid":"389967435","full_name":"spatie/flysystem-google-cloud-storage","owner":"spatie","description":"Flysystem v1 adapter for Google Cloud Storage","archived":false,"fork":false,"pushed_at":"2023-07-20T13:22:30.000Z","size":69,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-05-09T22:24:31.302Z","etag":null,"topics":["flysystem","google-cloud","php"],"latest_commit_sha":null,"homepage":"https://spatie.be/open-source","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"spatie"}},"created_at":"2021-07-27T12:04:35.000Z","updated_at":"2023-10-21T01:49:13.000Z","dependencies_parsed_at":"2024-01-15T09:06:31.151Z","dependency_job_id":"0784768b-a90a-4565-89e1-13f37c9b99d5","html_url":"https://github.com/spatie/flysystem-google-cloud-storage","commit_stats":{"total_commits":32,"total_committers":5,"mean_commits":6.4,"dds":0.5,"last_synced_commit":"d030ee3f4fbd1e6c92d27472abc6b846df0e4dc4"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":"spatie/package-skeleton-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fflysystem-google-cloud-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fflysystem-google-cloud-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fflysystem-google-cloud-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fflysystem-google-cloud-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/flysystem-google-cloud-storage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250318649,"owners_count":21410969,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flysystem","google-cloud","php"],"created_at":"2024-11-10T02:08:37.899Z","updated_at":"2025-04-22T20:31:09.045Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://github.com/sponsors/spatie"],"categories":[],"sub_categories":[],"readme":"# Flysystem adapter for Google Cloud Storage\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/flysystem-google-cloud-storage.svg?style=flat-square)](https://packagist.org/packages/spatie/flysystem-google-cloud-storage)\n[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/spatie/flysystem-google-cloud-storage/Tests/main?label=tests)](https://github.com/spatie/flysystem-google-cloud-storage/actions?query=workflow%3ATests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/spatie/flysystem-google-cloud-storage/Check%20\u0026%20fix%20styling/main?label=code%20style)](https://github.com/spatie/flysystem-google-cloud-storage/actions?query=workflow%3A\"Check+%26+fix+styling\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/flysystem-google-cloud-storage.svg?style=flat-square)](https://packagist.org/packages/spatie/flysystem-google-cloud-storage)\n\nThis package contains a [Google Cloud Storage](https://cloud.google.com/storage) driver for [Flysystem v1](https://flysystem.thephpleague.com). \n\n(If you need Google Cloud Storage support on Flysystem v2 or above (or Laravel 9), this package is not for you)\n\n### Notice\n\nThis package is a fork from [superbalist/flysystem-google-cloud-storage](https://github.com/Superbalist/flysystem-google-cloud-storage). Changes include:\n\n- PHP 8 only\n- merged random open PRs from Superbalist's package\n\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/flysystem-google-cloud-storage.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/flysystem-google-cloud-storage)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source)\n. You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are\nusing. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received\npostcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require spatie/flysystem-google-cloud-storage\n```\n\n## Authentication\n\nBefore 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.\n\n1. 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.\n2. The client will look for the credentials file at the following paths:\n    - Windows: `%APPDATA%/gcloud/application_default_credentials.json`\n    - MacOS/Unix: `$HOME/.config/gcloud/application_default_credentials.json`\n3. 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.\n\nUsing this in a Kubernetes cluster? Take a look at [Workload Identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity).\n\n## Usage\n\nHere's an example that shows you have you can call the various functions to manipulate files on Google Cloud.\n\n```php\nuse Google\\Cloud\\Storage\\StorageClient;\nuse League\\Flysystem\\Filesystem;\nuse Spatie\\GoogleCloudStorageAdapter\\GoogleCloudStorageAdapter;\n\n$storageClient = new StorageClient([\n    'projectId' =\u003e 'your-project-id',\n    // The credentials can manually be specified by passing in a keyFilePath.\n    // 'keyFilePath' =\u003e '/path/to/service-account.json',\n]);\n\n$bucket = $storageClient-\u003ebucket('your-bucket-name');\n\n$adapter = new GoogleCloudStorageAdapter($storageClient, $bucket);\n\n$filesystem = new Filesystem($adapter);\n\n$filesystem-\u003ewrite('path/to/file.txt', 'contents');\n$filesystem-\u003eupdate('path/to/file.txt', 'new contents');\n$contents = $filesystem-\u003eread('path/to/file.txt');\n$exists = $filesystem-\u003ehas('path/to/file.txt');\n$filesystem-\u003edelete('path/to/file.txt');\n$filesystem-\u003erename('filename.txt', 'newname.txt');\n$filesystem-\u003ecopy('filename.txt', 'duplicate.txt');\n$filesystem-\u003edeleteDir('path/to/directory');\n```\n\nSee [https://flysystem.thephpleague.com/v1/docs/usage/filesystem-api/](https://flysystem.thephpleague.com/v1/docs/usage/filesystem-api/) for full list of available functionality\n\n### Using a custom storage URI\n\nYou 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).\n\nWhen using a custom storage URI, the bucket name will not prepended to the file path:\n\n```php\nuse Google\\Cloud\\Storage\\StorageClient;\nuse League\\Flysystem\\Filesystem;\nuse Spatie\\GoogleCloudStorageAdapter\\GoogleCloudStorageAdapter;\n\n$storageClient = new StorageClient([\n    'projectId' =\u003e 'your-project-id',\n]);\n$bucket = $storageClient-\u003ebucket('your-bucket-name');\n$adapter = new GoogleCloudStorageAdapter($storageClient, $bucket);\n\n// URI defaults to \"https://storage.googleapis.com\":\n$filesystem = new Filesystem($adapter);\n$filesystem-\u003egetUrl('path/to/file.txt');\n// \"https://storage.googleapis.com/your-bucket-name/path/to/file.txt\"\n\n// Using custom storage uri:\n$adapter-\u003esetStorageApiUri('http://example.com');\n$filesystem = new Filesystem($adapter);\n$filesystem-\u003egetUrl('path/to/file.txt');\n// \"http://example.com/path/to/file.txt\"\n\n// You can also prefix the file path if needed:\n$adapter-\u003esetStorageApiUri('http://example.com');\n$adapter-\u003esetPathPrefix('extra-folder/another-folder/');\n$filesystem = new Filesystem($adapter);\n$filesystem-\u003egetUrl('path/to/file.txt');\n// \"http://example.com/extra-folder/another-folder/path/to/file.txt\"\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Alex Vanderbist](https://github.com/alexvanderbist)\n- [All Contributors](../../contributors)\n- [Superbalist](https://github.com/Superbalist) for the initial package\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fflysystem-google-cloud-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Fflysystem-google-cloud-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fflysystem-google-cloud-storage/lists"}