Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

google/cloud-storage v1.37.0

Cloud Storage Client for PHP
Package summary
Share
0
issues
0
licenses
Package created
10 Mar 2017
Version published
12 Jan 2024
Maintainers
2
Total deps
0
Direct deps
0
License
Apache-2.0
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does google/cloud-storage do?

Google/Cloud-Storage is a PHP client that facilitates world-wide storage and retrieval of any amount of data at any time. It is designed 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.

How do you use google/cloud-storage?

To use Google/Cloud-Storage, start by installing the dependency manager for PHP, Composer. Use the following command to install just the Google/Cloud-Storage component:

$ composer require google/cloud-storage

To install the complete suite, use:

$ composer require google/cloud

Authenticate your client as per the Authentication guide. Once authenticated, you can make requests.

Here are some sample codes showing how to use Google/Cloud-Storage:

Upload a file to the bucket:

require 'vendor/autoload.php';

use Google\Cloud\Storage\StorageClient;

$storage = new StorageClient();

$bucket = $storage->bucket('my_bucket');

$bucket->upload(
    fopen('/data/file.txt', 'r')
);

Give read access to anyone with the URL while uploading a file:

$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');

Use Google Cloud Storage as a 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');

Where are the google/cloud-storage docs?

The Google/Cloud-Storage documentation can be found at API documentation. You can get more in-depth usage samples at the official repository. Complement your understanding with official Google Cloud Storage documentation.