All code in the snippets directory demonstrate how to invoke Cloud Storage Trasfer from PHP.
src/quickstart.php is a sample function to create and run a transfer job between two GCS buckets.
-
Enable APIs - Enable the Storage Transfer Service API and create a new project or select an existing project.
-
Download The Credentials - Click "Go to credentials" after enabling the APIs. Click "New Credentials" and select "Service Account Key". Create a new service account, use the JSON key type, and select "Create". Once downloaded, set the environment variable
GOOGLE_APPLICATION_CREDENTIALSto the path of the JSON key that was downloaded. -
Clone the repo and cd into this directory
$ git clone https://github.com/GoogleCloudPlatform/php-docs-samples $ cd php-docs-samples/storagetransfer -
Install dependencies via Composer. Run
php composer.phar install(if composer is installed locally) orcomposer install(if composer is installed globally).
To run the Storage Transfer Samples, run any of the files in src/ on the CLI:
$ php src/quickstart.php
Usage: quickstart.php $bucketName $sourceGcsBucketName $sinkGcsBucketName
@param string $projectId The Project ID
@param string $sourceGcsBucketName The Storage bucket name
@param string $sinkGcsBucketName The Storage bucket name
This sample uses the Cloud Storage Transfer Client Library for PHP. You can read the documentation for more details on API usage and use GitHub to browse the source and report issues.
- See CONTRIBUTING.md
- See LICENSE