Skip to content

Commit

Permalink
Introduce support for Cloud Spanner (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpedrie authored Mar 22, 2017
1 parent 6905c9c commit c272d1e
Show file tree
Hide file tree
Showing 492 changed files with 30,377 additions and 2,814 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
build/
composer.phar
composer.lock
docs/json/**/*.json
docs/json/*
vendor/
36 changes: 20 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
language: php

sudo: required
dist: trusty

matrix:
include:
- php: 5.5.38
- php: 5.6.25
- php: 7.0
- php: 7.1
- php: hhvm
group: edge
fast_finish: true
include:
- php: 5.5.38
- php: 5.6.25
- php: 7.0
- php: 7.1
- php: hhvm
group: edge
fast_finish: true

before_script:
- pecl install grpc || echo 'Failed to install grpc'
- composer install
- pecl install grpc || echo 'Failed to install grpc'
- composer install

script:
- ./dev/sh/tests
- vendor/bin/phpcs --standard=./phpcs-ruleset.xml
- ./dev/sh/build-docs
- ./dev/sh/tests
- vendor/bin/phpcs --standard=./phpcs-ruleset.xml
- ./dev/sh/build-docs

after_success:
- bash <(curl -s https://codecov.io/bash)
- ./dev/sh/push-docs
- bash <(curl -s https://codecov.io/bash)
- ./dev/sh/push-docs
- ./dev/sh/trigger-split
- cat ./build/snippets-uncovered.json

after_failure:
- echo "SNIPPET COVERAGE REPORT" && cat ./build/snippets-uncovered.json
145 changes: 116 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ This client supports the following Google Cloud Platform services at a [Beta](#v
* [Google Stackdriver Logging](#google-stackdriver-logging-beta) (Beta)
* [Google Cloud Datastore](#google-cloud-datastore-beta) (Beta)
* [Google Cloud Storage](#google-cloud-storage-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:
* [Google Cloud Natural Language](#google-cloud-natural-language-alpha) (Alpha)
* [Google Cloud Pub/Sub](#google-cloud-pubsub-alpha) (Alpha)
* [Google Cloud Speech](#google-cloud-speech-alpha) (Alpha)
* [Google Cloud Translation](#google-cloud-translation-alpha) (Alpha)
* [Google Cloud Vision](#google-cloud-vision-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).

Expand Down Expand Up @@ -61,6 +61,14 @@ foreach ($queryResults->rows() as $row) {
}
```

#### google/cloud-bigquery

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

```
$ require google/cloud-bigquery
```

## Google Stackdriver Logging (Beta)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/logging/loggingclient)
Expand Down Expand Up @@ -93,6 +101,14 @@ foreach ($entries as $entry) {
}
```

#### google/cloud-logging

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

```
$ require google/cloud-logging
```

## Google Cloud Datastore (Beta)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/datastore/datastoreclient)
Expand Down Expand Up @@ -124,6 +140,14 @@ $key = $datastore->key('Person', '12345328897844');
$entity = $datastore->lookup($key);
```

#### google/cloud-datastore

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

```
$ require google/cloud-datastore
```

## Google Cloud Storage (Beta)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/storage/storageclient)
Expand Down Expand Up @@ -152,6 +176,69 @@ $object = $bucket->object('file_backup.txt');
$object->downloadToFile('/data/file_backup.txt');
```

#### Stream Wrapper

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

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

```
$ require google/cloud-storage
```

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

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

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

```
$ require google/cloud-vision
```

## Google Cloud Translation (Alpha)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/translate/translateclient)
Expand Down Expand Up @@ -198,6 +285,14 @@ foreach ($languages as $language) {
}
```

#### google/cloud-translate

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

```
$ require google/cloud-translate
```

## Google Cloud Natural Language (Alpha)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/naturallanguage/naturallanguageclient)
Expand Down Expand Up @@ -237,6 +332,14 @@ foreach ($tokens as $token) {
}
```

#### google/cloud-natural-language

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

```
$ require google/cloud-natural-language
```

## Google Cloud Pub/Sub (Alpha)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/pubsub/pubsubclient)
Expand Down Expand Up @@ -276,6 +379,14 @@ foreach ($messages as $message) {
}
```

#### google/cloud-pubsub

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

```
$ require google/cloud-pubsub
```

## Google Cloud Speech (Alpha)

- [API Documentation](http://googlecloudplatform.github.io/google-cloud-php/#/docs/latest/speech/speechclient)
Expand Down Expand Up @@ -303,36 +414,12 @@ foreach ($results as $result) {
}
```

## Google Cloud Vision (Alpha)
#### google/cloud-speech

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

#### Preview

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

use Google\Cloud\Vision\VisionClient;
Google Cloud Speech can be installed separately by requiring the `google/cloud-speech` composer package:

$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";
}
}
```
$ require google/cloud-speech
```

## Caching Access Tokens
Expand Down
15 changes: 12 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"james-heinrich/getid3": "^1.9",
"erusev/parsedown": "^1.6",
"vierbergenlars/php-semver": "^3.0",
"google/proto-client-php": "^0.7",
"google/gax": "^0.6"
"google/proto-client-php": "^0.9",
"google/gax": "^0.8"
},
"suggest": {
"google/gax": "Required to support gRPC",
Expand All @@ -72,9 +72,18 @@
"psr-4": {
"Google\\Cloud\\Dev\\": "dev/src",
"Google\\Cloud\\Tests\\System\\": "tests/system"
}
},
"files": ["dev/src/Functions.php"]
},
"scripts": {
"google-cloud": "dev/google-cloud"
},
"extra": {
"component": {
"id": "google-cloud",
"target": "[email protected]:jdpedrie-gcp/google-cloud-php.git",
"path": "src",
"entry": "ServiceBuilder.php"
}
}
}
2 changes: 2 additions & 0 deletions dev/google-cloud
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require __DIR__ . '/../vendor/autoload.php';

use Google\Cloud\Dev\DocGenerator\Command\Docs;
use Google\Cloud\Dev\Release\Command\Release;
use Google\Cloud\Dev\Split\Command\Split;
use Symfony\Component\Console\Application;

if (!class_exists(Application::class)) {
Expand All @@ -33,4 +34,5 @@ if (!class_exists(Application::class)) {
$app = new Application;
$app->add(new Release(__DIR__));
$app->add(new Docs(__DIR__));
$app->add(new Split(__DIR__));
$app->run();
8 changes: 7 additions & 1 deletion dev/sh/build-docs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ set -ev
function buildDocs () {
echo "doc dir before generation:"
find docs
composer google-cloud docs

if [ -z "$TRAVIS_TAG" ]; then
./dev/google-cloud docs
else
./dev/google-cloud docs -r ${TRAVIS_TAG}
fi

echo "doc dir after generation:"
find docs
}
Expand Down
13 changes: 13 additions & 0 deletions dev/sh/compile-splitsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

mkdir $
export GOPATH=$TRAVIS_BUILD_DIR/go

go get -d github.com/libgit2/git2go
cd $GOPATH/src/github.com/libgit2/git2go
git checkout next
git submodule update --init
make install

go get github.com/splitsh/lite
go build -o $TRAVIS_BUILD_DIR/splitsh-lite github.com/splitsh/lite
19 changes: 5 additions & 14 deletions dev/sh/push-docs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,11 @@

set -ev

function generateDocs () {
echo "doc dir before generation:"
find docs
composer google-cloud docs
echo "doc dir after generation:"
find docs
}

function pushDocs () {
git submodule add -q -f -b gh-pages https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} ghpages
mkdir -p ghpages/json/${1}
cp -R docs/json/master/* ghpages/json/${1}
cp docs/overview.html ghpages/json/${1}
cp docs/toc.json ghpages/json/${1}
git submodule add -q -f -b gh-pages https://${GH_OAUTH_TOKEN}@github.com/${TRAVIS_REPO_SLUG} ghpages

rsync -aP docs/json/* ghpages/json/

cp docs/home.html ghpages/json
cp docs/manifest.json ghpages
cd ghpages
Expand All @@ -25,7 +16,7 @@ function pushDocs () {
git config user.email "[email protected]"
git commit -m "Updating docs for ${1}"
git status
git push -q https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} HEAD:gh-pages
git push -q https://${GH_OAUTH_TOKEN}@github.com/${TRAVIS_REPO_SLUG} HEAD:gh-pages
else
echo "Nothing to commit."
fi
Expand Down
10 changes: 10 additions & 0 deletions dev/sh/split
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')

SHA=`$TRAVIS_BUILD_DIR/splitsh-lite --prefix=$1`
git push -q \
"https://${GH_OAUTH_TOKEN}@github.com/$2" \
$SHA:master --force
9 changes: 9 additions & 0 deletions dev/sh/trigger-split
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [[ "$TRAVIS_JOB_NUMBER" == *.1 && -n "$TRAVIS_TAG" ]]; then
$(dirname $0)/compile-splitsh
git fetch --unshallow
composer google-cloud split
else
echo "Split occurs only in a tag run, and in the first matrix build"
fi
Loading

0 comments on commit c272d1e

Please sign in to comment.