Google Cloud Client Libraries for PHP
Idiomatic PHP client for Google Cloud Platform services.
This client supports the following Google Cloud Platform services at a General Availability quality level:
- Google Stackdriver Logging (GA)
- Google Cloud Datastore (GA)
- Google Cloud Storage (GA)
This client supports the following Google Cloud Platform services at a Beta quality level:
- Google BigQuery (Beta)
- Google Cloud Natural Language (Beta)
- Google Cloud Translation (Beta)
- Google Cloud Vision (Beta)
This client supports the following Google Cloud Platform services at an Alpha quality level:
- Google Cloud Pub/Sub (Alpha)
- Google Cloud Speech (Alpha)
If you need support for other Google APIs, please check out the Google APIs Client Library for PHP.
Quick Start
In order to use any of our libraries, you first need to go through the following steps:
- Select or create a Cloud Platform project.
- Enable billing for your project.
- Enable the API you'll want to use (e.g. Vision API or Datastore API).
- Setup Authentication.
Once these steps are done, you can install the individual package for the API you want to use. For instance, to call the Cloud Vision API you need to install the following:
$ composer require google/cloud-visionFrom there, you can then start using the client. Please see lower in this page for code examples to get you started or look at the README of each API located in a subfolder of this repo.
The google/cloud meta-package
We also provide a meta-package, google/cloud, which provides access to all of the APIs at once:
$ composer require google/cloudExample Applications
- getting-started-php -
A tutorial that demonstrates how to build a complete web application using Cloud Datastore, Cloud Storage, and Cloud Pub/Sub and deploy it to Google App Engine.
Google Cloud Storage (Beta)
Quick Start
$ require google/cloud-storage
Preview
require 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$storage = new StorageClient([
'projectId' => 'my_project'
]);
$bucket = $storage->bucket('my_bucket');
// Upload a file to the bucket.
$bucket->upload(
fopen('/data/file.txt', 'r')
);
// Download and store an object from the bucket locally.
$object = $bucket->object('file_backup.txt');
$object->downloadToFile('/data/file_backup.txt');Versioning
This library follows Semantic Versioning.
Please note it is currently under active development. Any release versioned
0.x.y is subject to backwards incompatible changes at any time.
GA: Libraries defined at a GA quality level are stable, and will not
introduce backwards-incompatible changes in any minor or patch releases. We will
address issues and requests with the highest priority.
Beta: Libraries defined at a Beta quality level are expected to be mostly
stable and we're working towards their release candidate. We will address issues
and requests with a higher priority.
Alpha: Libraries defined at an Alpha quality level are still a
work-in-progress and are more likely to get backwards-incompatible updates.
Contributing
Contributions to this library are always welcome and highly encouraged.
See CONTRIBUTING for more information on how to get started.
License
Apache 2.0 - See LICENSE for more information.