PHPackages                             iadj/gcloud - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. iadj/gcloud

ActiveLibrary[File &amp; Storage](/categories/file-storage)

iadj/gcloud
===========

Google Cloud Client Library that doesn't conflict against google/apiclient

v0.33.0(8y ago)022Apache-2.0PHPPHP &gt;=5.5

Since Mar 29Pushed 8y ago1 watchersCompare

[ Source](https://github.com/iadj/google-cloud-php)[ Packagist](https://packagist.org/packages/iadj/gcloud)[ Docs](http://github.com/GoogleCloudPlatform/google-cloud-php)[ RSS](/packages/iadj-gcloud/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (18)Versions (44)Used By (0)

Google Cloud PHP Client
=======================

[](#google-cloud-php-client)

> Idiomatic PHP client for [Google Cloud Platform](https://cloud.google.com/) services.

[![Travis Build Status](https://camo.githubusercontent.com/dfaabe029f523514ccdbcc75e1ac7702a062b17ae6ea5b5aa83b8c68b476ffe6/68747470733a2f2f7472617669732d63692e6f72672f476f6f676c65436c6f7564506c6174666f726d2f676f6f676c652d636c6f75642d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/GoogleCloudPlatform/google-cloud-php/) [![codecov](https://camo.githubusercontent.com/bac6c498554918de3d254331292dd1fbf79bf5b251c716eb1cd1349a26ac7214/68747470733a2f2f636f6465636f762e696f2f67682f676f6f676c65636c6f7564706c6174666f726d2f676f6f676c652d636c6f75642d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/googlecloudplatform/google-cloud-php)

- [Homepage](http://googlecloudplatform.github.io/google-cloud-php)
- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs)

This client supports the following Google Cloud Platform services at a [General Availability](#versioning) quality level:

- [Google Stackdriver Logging](#google-stackdriver-logging-ga) (GA)
- [Google Cloud Datastore](#google-cloud-datastore-ga) (GA)
- [Google Cloud Storage](#google-cloud-storage-ga) (GA)
- [Google Cloud Translation](#google-cloud-translation-ga) (GA)

This client supports the following Google Cloud Platform services at a [Beta](#versioning) quality level:

- [Google BigQuery](#google-bigquery-beta) (Beta)
- [Google Cloud Natural Language](#google-cloud-natural-language-beta) (Beta)
- [Google Cloud Pub/Sub](#google-cloud-pubsub-beta) (Beta)
- [Google Cloud Vision](#google-cloud-vision-beta) (Beta)

This client supports the following Google Cloud Platform services at an [Alpha](#versioning) quality level:

- [Cloud Spanner](#cloud-spanner-alpha) (Alpha)
- [Google Cloud Speech](#google-cloud-speech-alpha) (Alpha)
- [Google Cloud Video Intelligence](#google-cloud-video-intelligence-alpha) (Alpha)
- [Google Stackdriver Trace](#google-stackdriver-trace-alpha) (Alpha)

If you need support for other Google APIs, please check out the [Google APIs Client Library for PHP](https://github.com/google/google-api-php-client).

Quick Start
-----------

[](#quick-start)

```
$ composer require google/cloud
```

Google Stackdriver Logging (GA)
-------------------------------

[](#google-stackdriver-logging-ga)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/logging/loggingclient)
- [Official Documentation](https://cloud.google.com/logging/docs)

#### Preview

[](#preview)

```
require 'vendor/autoload.php';

use Google\Cloud\Logging\LoggingClient;

$logging = new LoggingClient([
    'projectId' => 'my_project'
]);

// Get a logger instance.
$logger = $logging->logger('my_log');

// Write a log entry.
$logger->write('my message');

// List log entries from a specific log.
$entries = $logging->entries([
    'filter' => 'logName = projects/my_project/logs/my_log'
]);

foreach ($entries as $entry) {
    echo $entry->info()['textPayload'] . "\n";
}
```

#### google/cloud-logging

[](#googlecloud-logging)

Google Stackdriver Logging can be installed separately by requiring the `google/cloud-logging` composer package:

```
$ require google/cloud-logging

```

Google Cloud Datastore (GA)
---------------------------

[](#google-cloud-datastore-ga)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/datastore/datastoreclient)
- [Official Documentation](https://cloud.google.com/datastore/docs/)

#### Preview

[](#preview-1)

```
require 'vendor/autoload.php';

use Google\Cloud\Datastore\DatastoreClient;

$datastore = new DatastoreClient([
    'projectId' => 'my_project'
]);

// Create an entity
$bob = $datastore->entity('Person');
$bob['firstName'] = 'Bob';
$bob['email'] = 'bob@example.com';
$datastore->insert($bob);

// Update the entity
$bob['email'] = 'bobV2@example.com';
$datastore->update($bob);

// If you know the ID of the entity, you can look it up
$key = $datastore->key('Person', '12345328897844');
$entity = $datastore->lookup($key);
```

#### google/cloud-datastore

[](#googlecloud-datastore)

Google Cloud Datastore can be installed separately by requiring the `google/cloud-datastore` composer package:

```
$ require google/cloud-datastore

```

Google Cloud Storage (GA)
-------------------------

[](#google-cloud-storage-ga)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/storage/storageclient)
- [Official Documentation](https://cloud.google.com/storage/docs)

#### Preview

[](#preview-2)

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

// Using Predefined ACLs to manage object permissions, you may
// upload a file and give read access to anyone with the URL.
$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');
```

#### Stream Wrapper

[](#stream-wrapper)

```
require 'vendor/autoload.php';

use Google\Cloud\Storage\StorageClient;

$storage = new StorageClient([
    'projectId' => 'my_project'
]);
$storage->registerStreamWrapper();

$contents = file_get_contents('gs://my_bucket/file_backup.txt');
```

#### google/cloud-storage

[](#googlecloud-storage)

Google Cloud Storage can be installed separately by requiring the `google/cloud-storage` composer package:

```
$ require google/cloud-storage

```

Google Cloud Translation (GA)
-----------------------------

[](#google-cloud-translation-ga)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/translate/translateclient)
- [Official Documentation](https://cloud.google.com/translation/docs)

#### Preview

[](#preview-3)

```
require 'vendor/autoload.php';

use Google\Cloud\Translate\TranslateClient;

$translate = new TranslateClient([
    'key' => 'your_key'
]);

// Translate text from english to french.
$result = $translate->translate('Hello world!', [
    'target' => 'fr'
]);

echo $result['text'] . "\n";

// Detect the language of a string.
$result = $translate->detectLanguage('Greetings from Michigan!');

echo $result['languageCode'] . "\n";

// Get the languages supported for translation specifically for your target language.
$languages = $translate->localizedLanguages([
    'target' => 'en'
]);

foreach ($languages as $language) {
    echo $language['name'] . "\n";
    echo $language['code'] . "\n";
}

// Get all languages supported for translation.
$languages = $translate->languages();

foreach ($languages as $language) {
    echo $language . "\n";
}
```

#### google/cloud-translate

[](#googlecloud-translate)

Google Cloud Translation can be installed separately by requiring the `google/cloud-translate` composer package:

```
$ require google/cloud-translate

```

Google BigQuery (Beta)
----------------------

[](#google-bigquery-beta)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/bigquery/bigqueryclient)
- [Official Documentation](https://cloud.google.com/bigquery/docs)

#### Preview

[](#preview-4)

```
require 'vendor/autoload.php';

use Google\Cloud\BigQuery\BigQueryClient;

$bigQuery = new BigQueryClient([
    'projectId' => 'my_project'
]);

// Get an instance of a previously created table.
$dataset = $bigQuery->dataset('my_dataset');
$table = $dataset->table('my_table');

// Begin a job to import data from a CSV file into the table.
$job = $table->load(
    fopen('/data/my_data.csv', 'r')
);

// Run a query and inspect the results.
$queryResults = $bigQuery->runQuery('SELECT * FROM [my_project:my_dataset.my_table]');

foreach ($queryResults->rows() as $row) {
    print_r($row);
}
```

#### google/cloud-bigquery

[](#googlecloud-bigquery)

Google BigQuery can be installed separately by requiring the `google/cloud-bigquery` composer package:

```
$ require google/cloud-bigquery

```

Google Cloud Natural Language (Beta)
------------------------------------

[](#google-cloud-natural-language-beta)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/language/languageclient)
- [Official Documentation](https://cloud.google.com/natural-language/docs)

#### Preview

[](#preview-5)

```
require 'vendor/autoload.php';

use Google\Cloud\Language\LanguageClient;

$language = new LanguageClient([
    'projectId' => 'my_project'
]);

// Analyze a sentence.
$annotation = $language->annotateText('Greetings from Michigan!');

// Check the sentiment.
if ($annotation->sentiment() > 0) {
    echo "This is a positive message.\n";
}

// Detect entities.
$entities = $annotation->entitiesByType('LOCATION');

foreach ($entities as $entity) {
    echo $entity['name'] . "\n";
}

// Parse the syntax.
$tokens = $annotation->tokensByTag('NOUN');

foreach ($tokens as $token) {
    echo $token['text']['content'] . "\n";
}
```

#### google/cloud-language

[](#googlecloud-language)

Google Cloud Natural Language can be installed separately by requiring the `google/cloud-language` composer package:

```
$ require google/cloud-language

```

Google Cloud Pub/Sub (Beta)
---------------------------

[](#google-cloud-pubsub-beta)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/pubsub/pubsubclient)
- [Official Documentation](https://cloud.google.com/pubsub/docs)

#### Preview

[](#preview-6)

```
require 'vendor/autoload.php';

use Google\Cloud\PubSub\PubSubClient;

$pubSub = new PubSubClient([
    'projectId' => 'my_project'
]);

// Get an instance of a previously created topic.
$topic = $pubSub->topic('my_topic');

// Publish a message to the topic.
$topic->publish([
    'data' => 'My new message.',
    'attributes' => [
        'location' => 'Detroit'
    ]
]);

// Get an instance of a previously created subscription.
$subscription = $pubSub->subscription('my_subscription');

// Pull all available messages.
$messages = $subscription->pull();

foreach ($messages as $message) {
    echo $message->data() . "\n";
    echo $message->attribute('location');
}
```

#### google/cloud-pubsub

[](#googlecloud-pubsub)

Google Cloud Pub/Sub can be installed separately by requiring the `google/cloud-pubsub` composer package:

```
$ require google/cloud-pubsub

```

Google Cloud Vision (Beta)
--------------------------

[](#google-cloud-vision-beta)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/vision/visionclient)
- [Official Documentation](https://cloud.google.com/vision/docs)

#### Preview

[](#preview-7)

```
require 'vendor/autoload.php';

use Google\Cloud\Vision\VisionClient;

$vision = new VisionClient([
    'projectId' => 'my_project'
]);

// Annotate an image, detecting faces.
$image = $vision->image(
    fopen('/data/family_photo.jpg', 'r'),
    ['faces']
);

$annotation = $vision->annotate($image);

// Determine if the detected faces have headwear.
foreach ($annotation->faces() as $key => $face) {
    if ($face->hasHeadwear()) {
        echo "Face $key has headwear.\n";
    }
}
```

#### google/cloud-vision

[](#googlecloud-vision)

Google Cloud Vision can be installed separately by requiring the `google/cloud-vision` composer package:

```
$ require google/cloud-vision

```

Cloud Spanner (Alpha)
---------------------

[](#cloud-spanner-alpha)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/spanner/spannerclient)
- [Official Documentation](https://cloud.google.com/spanner/docs)

#### Preview

[](#preview-8)

```
require 'vendor/autoload.php';

use Google\Cloud\Spanner\SpannerClient;

$spanner = new SpannerClient([
    'projectId' => 'my_project'
]);

$db = $spanner->connect('my-instance', 'my-database');

$userQuery = $db->execute('SELECT * FROM Users WHERE id = @id', [
    'parameters' => [
        'id' => $userId
    ]
]);

$user = $userQuery->rows()->current();

echo 'Hello ' . $user['firstName'];
```

#### google/cloud-spanner

[](#googlecloud-spanner)

Cloud Spanner can be installed separately by requiring the `google/cloud-spanner` composer package:

```
$ require google/cloud-spanner

```

Google Cloud Speech (Alpha)
---------------------------

[](#google-cloud-speech-alpha)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/speech/speechclient)
- [Official Documentation](https://cloud.google.com/speech/docs)

#### Preview

[](#preview-9)

```
require 'vendor/autoload.php';

use Google\Cloud\Speech\SpeechClient;

$speech = new SpeechClient([
    'projectId' => 'my_project',
    'languageCode' => 'en-US'
]);

// Recognize the speech in an audio file.
$results = $speech->recognize(
    fopen(__DIR__ . '/audio_sample.flac', 'r')
);

foreach ($results as $result) {
    echo $result->topAlternative()['transcript'] . "\n";
}
```

#### google/cloud-speech

[](#googlecloud-speech)

Google Cloud Speech can be installed separately by requiring the `google/cloud-speech` composer package:

```
$ require google/cloud-speech

```

Google Cloud Video Intelligence (Alpha)
---------------------------------------

[](#google-cloud-video-intelligence-alpha)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/videointelligence/readme)
- [Official Documentation](https://cloud.google.com/video-intelligence/docs)

#### Preview

[](#preview-10)

```
require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\VideoIntelligence\V1beta1\VideoIntelligenceServiceClient;
use google\cloud\videointelligence\v1beta1\Feature;

$client = new VideoIntelligenceServiceClient();

$inputUri = "gs://example-bucket/example-video.mp4";
$features = [
    Feature::LABEL_DETECTION,
];
$operationResponse = $client->annotateVideo($inputUri, $features);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
    $results = $operationResponse->getResult();
    foreach ($results->getAnnotationResultsList() as $result) {
        foreach ($result->getLabelAnnotationsList() as $labelAnnotation) {
            echo "Label: " . $labelAnnotation->getDescription() . "\n";
        }
    }
} else {
    $error = $operationResponse->getError();
    echo "error: " . $error->getMessage() . "\n";
}
```

#### google/cloud-videointelligence

[](#googlecloud-videointelligence)

Cloud Video Intelligence can be installed separately by requiring the `google/cloud-videointelligence` composer package:

```
$ require google/cloud-videointelligence

```

Google Stackdriver Trace (Alpha)
--------------------------------

[](#google-stackdriver-trace-alpha)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/trace/traceclient)
- [Official Documentation](https://cloud.google.com/trace/docs)

#### Preview

[](#preview-11)

```
require 'vendor/autoload.php';

use Google\Cloud\Trace\TraceClient;

$traceClient = new TraceClient([
    'projectId' => 'my_project'
]);

// Create a Trace
$trace = $traceClient->trace();
$span = $trace->span([
    'name' => 'main'
]);
$span->setStart();
$span->setEnd();

$trace->setSpans([$span]);
$traceClient->insert($trace);

// List recent Traces
foreach($traceClient->traces() as $trace) {
    var_dump($trace->traceId());
}
```

#### google/cloud-trace

[](#googlecloud-trace)

Stackdriver Trace can be installed separately by requiring the `google/cloud-trace` composer package:

```
$ require google/cloud-trace

```

Caching Access Tokens
---------------------

[](#caching-access-tokens)

By default the library will use a simple in-memory caching implementation, however it is possible to override this behavior by passing a [PSR-6](http://www.php-fig.org/psr/psr-6/) caching implementation in to the desired client.

The following example takes advantage of [Symfony's Cache Component](https://github.com/symfony/cache).

```
require 'vendor/autoload.php';

use Google\Cloud\Storage\StorageClient;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

// Please take the proper precautions when storing your access tokens in a cache no matter the implementation.
$cache = new ArrayAdapter();

$storage = new StorageClient([
    'authCache' => $cache
]);
```

Versioning
----------

[](#versioning)

This library follows [Semantic Versioning](http://semver.org/).

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
------------

[](#contributing)

Contributions to this library are always welcome and highly encouraged.

See [CONTRIBUTING](CONTRIBUTING.md) for more information on how to get started.

License
-------

[](#license)

Apache 2.0 - See [LICENSE](LICENSE) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~11 days

Total

42

Last Release

3241d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bacd7443dbf5e20c48f7b5a5341be56757f110d21aa5aab730c6d68a72270f9f?d=identicon)[iadj](/maintainers/iadj)

---

Top Contributors

[![dwsupplee](https://avatars.githubusercontent.com/u/2079879?v=4)](https://github.com/dwsupplee "dwsupplee (151 commits)")[![jdpedrie](https://avatars.githubusercontent.com/u/89034?v=4)](https://github.com/jdpedrie "jdpedrie (141 commits)")[![michaelbausor](https://avatars.githubusercontent.com/u/14846209?v=4)](https://github.com/michaelbausor "michaelbausor (25 commits)")[![bshaffer](https://avatars.githubusercontent.com/u/103941?v=4)](https://github.com/bshaffer "bshaffer (14 commits)")[![chingor13](https://avatars.githubusercontent.com/u/32483?v=4)](https://github.com/chingor13 "chingor13 (6 commits)")[![mcrumm](https://avatars.githubusercontent.com/u/168677?v=4)](https://github.com/mcrumm "mcrumm (4 commits)")[![cedricziel](https://avatars.githubusercontent.com/u/418970?v=4)](https://github.com/cedricziel "cedricziel (3 commits)")[![adhiravishankar](https://avatars.githubusercontent.com/u/3884741?v=4)](https://github.com/adhiravishankar "adhiravishankar (2 commits)")[![adriankirchner](https://avatars.githubusercontent.com/u/149483?v=4)](https://github.com/adriankirchner "adriankirchner (2 commits)")[![iadj](https://avatars.githubusercontent.com/u/8861459?v=4)](https://github.com/iadj "iadj (2 commits)")[![danoscarmike](https://avatars.githubusercontent.com/u/3130752?v=4)](https://github.com/danoscarmike "danoscarmike (1 commits)")[![garrettjonesgoogle](https://avatars.githubusercontent.com/u/13341017?v=4)](https://github.com/garrettjonesgoogle "garrettjonesgoogle (1 commits)")[![y33zhang](https://avatars.githubusercontent.com/u/22893349?v=4)](https://github.com/y33zhang "y33zhang (1 commits)")[![callmehiphop](https://avatars.githubusercontent.com/u/1707267?v=4)](https://github.com/callmehiphop "callmehiphop (1 commits)")[![jgeewax](https://avatars.githubusercontent.com/u/112928?v=4)](https://github.com/jgeewax "jgeewax (1 commits)")[![kop](https://avatars.githubusercontent.com/u/645148?v=4)](https://github.com/kop "kop (1 commits)")[![bencromwell](https://avatars.githubusercontent.com/u/683855?v=4)](https://github.com/bencromwell "bencromwell (1 commits)")[![amoiseiev](https://avatars.githubusercontent.com/u/4966014?v=4)](https://github.com/amoiseiev "amoiseiev (1 commits)")[![omaray](https://avatars.githubusercontent.com/u/6609430?v=4)](https://github.com/omaray "omaray (1 commits)")[![povils](https://avatars.githubusercontent.com/u/11535217?v=4)](https://github.com/povils "povils (1 commits)")

---

Tags

languagetranslatecloudgoogletranslationstoragegcsgoogle apivisionpub-subnatural-languagepubsubdatastorespeechgoogle cloudbigquerygoogle apis clientgoogle api clientgoogle apisgoogle cloud platformbig querystackdriver loggingspanner

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/iadj-gcloud/health.svg)

```
[![Health](https://phpackages.com/badges/iadj-gcloud/health.svg)](https://phpackages.com/packages/iadj-gcloud)
```

###  Alternatives

[google/cloud

Google Cloud Client Library

1.2k16.2M53](/packages/google-cloud)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k511.3M2.2k](/packages/aws-aws-sdk-php)[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

343121.4M79](/packages/google-cloud-core)[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
