Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

As PHP version 5.5 is no longer supported by the community, we strongly recommend new apps use the PHP 7+ runtime.

Setup

Stay organized with collections Save and categorize content based on your preferences.

Your PHP 5 app requires a properly configured Google Cloud Storage bucket. Fortunately, each app can easily gain access to such a bucket if you do the following:

  1. Enable billing for your project, if you haven't already done so.
  2. Click Create bucket in the Storage Browser for your project.

Note you might incur costs by using a Cloud Storage bucket. Each project can have a default bucket, which includes 5GB of free storage and a free quota for I/O operations.

Useful tricks when using default buckets

When using a default bucket, you don't actually need to know your bucket name: you can use #default# and this will be replaced at runtime by the name of the default bucket.

For example, you would write to the default bucket using the App Engine stream wrapper for Cloud Storage:

$default_bucket = CloudStorageTools::getDefaultGoogleStorageBucketName();
file_put_contents("gs://${default_bucket}/hello_default.txt", $newFileContent);

or

$default_bucket = CloudStorageTools::getDefaultGoogleStorageBucketName();
$fp = fopen("gs://${default_bucket}/hello_default_stream.txt", 'w');
fwrite($fp, $newFileContent);
fclose($fp);