{"id":13545619,"url":"https://github.com/Superbalist/laravel-google-cloud-storage","last_synced_at":"2025-04-02T15:31:36.628Z","repository":{"id":11334710,"uuid":"69335011","full_name":"Superbalist/laravel-google-cloud-storage","owner":"Superbalist","description":"A Google Cloud Storage filesystem for Laravel","archived":true,"fork":false,"pushed_at":"2022-07-04T13:15:42.000Z","size":35,"stargazers_count":509,"open_issues_count":37,"forks_count":145,"subscribers_count":38,"default_branch":"master","last_synced_at":"2025-02-19T19:44:39.778Z","etag":null,"topics":["flysystem","flysystem-adapter","flysystem-google-cloud-storage","google-cloud","google-cloud-platform","google-cloud-storage","google-storage","laravel","laravel-google-cloud-storage","laravel5","laravel5-package","php","superbalist"],"latest_commit_sha":null,"homepage":null,"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/Superbalist.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2016-09-27T08:22:04.000Z","updated_at":"2025-01-25T19:03:37.000Z","dependencies_parsed_at":"2022-08-07T06:01:21.374Z","dependency_job_id":null,"html_url":"https://github.com/Superbalist/laravel-google-cloud-storage","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Superbalist%2Flaravel-google-cloud-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Superbalist%2Flaravel-google-cloud-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Superbalist%2Flaravel-google-cloud-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Superbalist%2Flaravel-google-cloud-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Superbalist","download_url":"https://codeload.github.com/Superbalist/laravel-google-cloud-storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246841806,"owners_count":20842649,"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","flysystem-adapter","flysystem-google-cloud-storage","google-cloud","google-cloud-platform","google-cloud-storage","google-storage","laravel","laravel-google-cloud-storage","laravel5","laravel5-package","php","superbalist"],"created_at":"2024-08-01T11:01:07.199Z","updated_at":"2025-04-02T15:31:31.614Z","avatar_url":"https://github.com/Superbalist.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# laravel-google-cloud-storage\n\nA Google Cloud Storage filesystem for Laravel.\n\n[![Author](http://img.shields.io/badge/author-@superbalist-blue.svg?style=flat-square)](https://twitter.com/superbalist)\n[![Build Status](https://img.shields.io/travis/Superbalist/laravel-google-cloud-storage/master.svg?style=flat-square)](https://travis-ci.org/Superbalist/laravel-google-cloud-storage)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Packagist Version](https://img.shields.io/packagist/v/superbalist/laravel-google-cloud-storage.svg?style=flat-square)](https://packagist.org/packages/superbalist/laravel-google-cloud-storage)\n[![Total Downloads](https://img.shields.io/packagist/dt/superbalist/laravel-google-cloud-storage.svg?style=flat-square)](https://packagist.org/packages/superbalist/laravel-google-cloud-storage)\n\nThis package is a wrapper bridging [flysystem-google-storage](https://github.com/Superbalist/flysystem-google-storage) into Laravel as an available storage disk.\n\n## Installation\n\n```bash\ncomposer require superbalist/laravel-google-cloud-storage\n```\n\nIf you are on Laravel 5.4 or earlier, then register the service provider in app.php\n```php\n'providers' =\u003e [\n    // ...\n    Superbalist\\LaravelGoogleCloudStorage\\GoogleCloudStorageServiceProvider::class,\n]\n```\n\nIf you are on Laravel 5.5 or higher, composer will have registered the provider automatically for you.\n\nAdd a new disk to your `filesystems.php` config\n\n```php\n'gcs' =\u003e [\n    'driver' =\u003e 'gcs',\n    'project_id' =\u003e env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'),\n    'key_file' =\u003e env('GOOGLE_CLOUD_KEY_FILE', null), // optional: /path/to/service-account.json\n    'bucket' =\u003e env('GOOGLE_CLOUD_STORAGE_BUCKET', 'your-bucket'),\n    'path_prefix' =\u003e env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', null), // optional: /default/path/to/apply/in/bucket\n    'storage_api_uri' =\u003e env('GOOGLE_CLOUD_STORAGE_API_URI', null), // see: Public URLs below\n    'visibility' =\u003e 'public', // optional: public|private\n],\n```\n\n### Authentication\n\nThe Google Client uses a few methods to determine how it should authenticate with the Google API.\n\n1. If you specify a path in the key `key_file` in  disk config, that json credentials file will be used.\n2. If the `GOOGLE_APPLICATION_CREDENTIALS` env var is set, it will use that.\n   ```php\n   putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');\n   ```\n3. It will then try load the key file from a 'well known path':\n   * windows: %APPDATA%/gcloud/application_default_credentials.json\n   * others: $HOME/.config/gcloud/application_default_credentials.json\n\n4. If running in **Google App Engine**, the built-in service account associated with the application will be used.\n5. If running in **Google Compute Engine**, the built-in service account associated with the virtual machine instance will be used.\n6. 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:\n    ```php\n    'key_file' =\u003e [\n        'type' =\u003e env('GOOGLE_CLOUD_ACCOUNT_TYPE'),\n        'private_key_id' =\u003e env('GOOGLE_CLOUD_PRIVATE_KEY_ID'),\n        'private_key' =\u003e env('GOOGLE_CLOUD_PRIVATE_KEY'),\n        'client_email' =\u003e env('GOOGLE_CLOUD_CLIENT_EMAIL'),\n        'client_id' =\u003e env('GOOGLE_CLOUD_CLIENT_ID'),\n        'auth_uri' =\u003e env('GOOGLE_CLOUD_AUTH_URI'),\n        'token_uri' =\u003e env('GOOGLE_CLOUD_TOKEN_URI'),\n        'auth_provider_x509_cert_url' =\u003e env('GOOGLE_CLOUD_AUTH_PROVIDER_CERT_URL'),\n        'client_x509_cert_url' =\u003e env('GOOGLE_CLOUD_CLIENT_CERT_URL'),\n    ],\n    ```\n\n### Public URLs\n\nThe adapter implements a `getUrl($path)` method which returns a public url to a file.\n\u003e**Note:** Method available for Laravel 5.2 and higher. If used on 5.1, it will throw an exception.\n\n```php\n$disk = Storage::disk('gcs');\n$url = $disk-\u003eurl('folder/my_file.txt');\n\u003e\u003e\u003e http://storage.googleapis.com/bucket-name/folder/my_file.txt\n```\n\nIf you configure a `path_prefix` in your config:\n```php\n$disk = Storage::disk('gcs');\n$url = $disk-\u003eurl('folder/my_file.txt');\n\u003e\u003e\u003e http://storage.googleapis.com/bucket-name/path-prefix/folder/my_file.txt\n```\n\nIf you configure a custom `storage_api_uri` in your config:\n```php\n$disk = Storage::disk('gcs');\n$url = $disk-\u003eurl('folder/my_file.txt');\n\u003e\u003e\u003e http://your-custom-domain.com/bucket-name/path-prefix/folder/my_file.txt\n```\n\nFor a custom domain (storage api uri), you will need to configure a CNAME DNS entry pointing to `storage.googleapis.com`.\n\nPlease see https://cloud.google.com/storage/docs/xml-api/reference-uris#cname for further instructions.\n\n## Usage\n\n```php\n$disk = Storage::disk('gcs');\n\n// create a file\n$disk-\u003eput('avatars/1', $fileContents);\n\n// check if a file exists\n$exists = $disk-\u003eexists('file.jpg');\n\n// get file modification date\n$time = $disk-\u003elastModified('file1.jpg');\n\n// copy a file\n$disk-\u003ecopy('old/file1.jpg', 'new/file1.jpg');\n\n// move a file\n$disk-\u003emove('old/file1.jpg', 'new/file1.jpg');\n\n// get url to file\n$url = $disk-\u003eurl('folder/my_file.txt');\n\n// Set the visibility of file to public\n$disk-\u003esetVisibility('folder/my_file.txt', 'public');\n\n\n// See https://laravel.com/docs/5.3/filesystem for full list of available functionality\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSuperbalist%2Flaravel-google-cloud-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSuperbalist%2Flaravel-google-cloud-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSuperbalist%2Flaravel-google-cloud-storage/lists"}