NOTE: This repository is part of Google Cloud PHP. Any
support requests, bug reports, or development contributions should be directed to
that project.
Allows world-wide storage and retrieval of any amount of data at any time. You can use Cloud Storage for a range of
scenarios including serving website content, storing data for archival and disaster recovery, or distributing large data objects to users via direct download.
Installation
To begin, install the preferred dependency manager for PHP, Composer.
Now install this component:
$ composer require google/cloud-storage
Authentication
Please see our Authentication guide for more information
on authenticating your client. Once authenticated, you'll be ready to start making requests.
Sample
require 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$storage = new StorageClient();
$bucket = $storage->bucket('my_bucket');
// Upload a file to the bucket.
$bucket->upload(
fopen('/data/file.txt', 'r')
);
// Using Predefined ACLs to manage object permissions, you may
// upload a file and give read access to anyone with the URL.
$bucket->upload(
fopen('/data/file.txt', 'r'),
[
'predefinedAcl' => 'publicRead'
]
);
// Download and store an object from the bucket locally.
$object = $bucket->object('file_backup.txt');
$object->downloadToFile('/data/file_backup.txt');
Stream Wrapper
require 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$storage = new StorageClient();
$storage->registerStreamWrapper();
$contents = file_get_contents('gs://my_bucket/file_backup.txt');
Debugging
Please see our Debugging guide
for more information about the debugging tools.
Version
This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in
any minor or patch releases. We will address issues and requests with the highest priority.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["Version latestkeyboard_arrow_down\n\n- [1.48.3 (latest)](/php/docs/reference/cloud-storage/latest)\n- [1.48.2](/php/docs/reference/cloud-storage/1.48.2)\n- [1.47.0](/php/docs/reference/cloud-storage/1.47.0)\n- [1.46.0](/php/docs/reference/cloud-storage/1.46.0)\n- [1.45.0](/php/docs/reference/cloud-storage/1.45.0)\n- [1.44.0](/php/docs/reference/cloud-storage/1.44.0)\n- [1.43.1](/php/docs/reference/cloud-storage/1.43.1)\n- [1.42.1](/php/docs/reference/cloud-storage/1.42.1)\n- [1.41.4](/php/docs/reference/cloud-storage/1.41.4)\n- [1.37.0](/php/docs/reference/cloud-storage/1.37.0)\n- [1.36.1](/php/docs/reference/cloud-storage/1.36.1)\n- [1.35.0](/php/docs/reference/cloud-storage/1.35.0)\n- [1.34.0](/php/docs/reference/cloud-storage/1.34.0)\n- [1.33.4](/php/docs/reference/cloud-storage/1.33.4)\n- [1.32.0](/php/docs/reference/cloud-storage/1.32.0)\n- [1.31.2](/php/docs/reference/cloud-storage/1.31.2)\n- [1.30.3](/php/docs/reference/cloud-storage/1.30.3) \n\nGoogle Cloud Storage for PHP\n============================\n\n\u003e Idiomatic PHP client for [Cloud Storage](https://cloud.google.com/storage/).\n\n[](https://packagist.org/packages/google/cloud-storage) [](https://packagist.org/packages/google/cloud-storage)\n\n**NOTE:** This repository is part of [Google Cloud PHP](https://github.com/googleapis/google-cloud-php). Any\nsupport requests, bug reports, or development contributions should be directed to\nthat project.\n\nAllows world-wide storage and retrieval of any amount of data at any time. You can use Cloud Storage for a range of\nscenarios including serving website content, storing data for archival and disaster recovery, or distributing large data objects to users via direct download.\n\n### Installation\n\nTo begin, install the preferred dependency manager for PHP, [Composer](https://getcomposer.org/).\n\nNow install this component: \n\n $ composer require google/cloud-storage\n\n### Authentication\n\nPlease see our [Authentication guide](https://github.com/googleapis/google-cloud-php/blob/main/AUTHENTICATION.md) for more information\non authenticating your client. Once authenticated, you'll be ready to start making requests.\n\n### Sample\n\n require 'vendor/autoload.php';\n\n use Google\\Cloud\\Storage\\StorageClient;\n\n $storage = new StorageClient();\n\n $bucket = $storage-\u003ebucket('my_bucket');\n\n // Upload a file to the bucket.\n $bucket-\u003eupload(\n fopen('/data/file.txt', 'r')\n );\n\n // Using Predefined ACLs to manage object permissions, you may\n // upload a file and give read access to anyone with the URL.\n $bucket-\u003eupload(\n fopen('/data/file.txt', 'r'),\n [\n 'predefinedAcl' =\u003e 'publicRead'\n ]\n );\n\n // Download and store an object from the bucket locally.\n $object = $bucket-\u003eobject('file_backup.txt');\n $object-\u003edownloadToFile('/data/file_backup.txt');\n\n### Stream Wrapper\n\n require 'vendor/autoload.php';\n\n use Google\\Cloud\\Storage\\StorageClient;\n\n $storage = new StorageClient();\n $storage-\u003eregisterStreamWrapper();\n\n $contents = file_get_contents('gs://my_bucket/file_backup.txt');\n\n### Debugging\n\nPlease see our [Debugging guide](https://github.com/googleapis/google-cloud-php/blob/main/DEBUG.md)\nfor more information about the debugging tools.\n\n### Version\n\nThis component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in\nany minor or patch releases. We will address issues and requests with the highest priority.\n\n### Next Steps\n\n1. Understand the [official documentation](https://cloud.google.com/storage/docs).\n2. Take a look at [in-depth usage samples](https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/storage/)."]]