First, install the Google Cloud Client Library with composer and require it into your project:

$ composer require google/cloud

If you are running your app on Google Compute Engine, you won't need to worry about supplying connection configuration options to the library— we figure that out for you.

However, if you're running your app elsewhere, you will need to provide project details to authenticate API requests.

use Google\Cloud\Core\ServiceBuilder; // Compute Engine $gcloud = new ServiceBuilder([ 'projectId' => 'myProject' ]); // Elsewhere $gcloud = new ServiceBuilder([ 'keyFilePath' => '/path/to/key/file.json', 'projectId' => 'myProject' ]); // Fetch an instance of the Storage Client $storage = $gcloud->storage();

The full set of options which can be passed to the ServiceBuilder and sub-modules are outlined here.