Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ script:
- composer install
- phpunit mainTest.php
- phpunit utilTest.php
- cd ../..
# run datastore tests
- cd datastore
- composer install
- phpunit test
- cd ..
82 changes: 82 additions & 0 deletions datastore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Google Datastore PHP Sample Application

A simple app to make calls to the Datastore API

## Register your application

- Go to
[Google Developers Console](https://console.developers.google.com/project)
and create a new project. This will automatically enable an App
Engine application with the same ID as the project.

- Enable the "Google Cloud Datastore API" under "APIs & auth > APIs."

- edit `app.yaml` and change `MY_GCP_PROJECT_ID` to your App Engine project ID

- For local development also follow the instructions below.

- Go to "Credentials" and create a new Service Account.

- Select "Generate new JSON key", then download a new JSON file.

- Set the following environment variables:

- `GOOGLE_APPLICATION_CREDENTIALS`: the file path to the downloaded JSON file.
- `GCP_PROJECT_ID`: Your app engine project ID

## Prerequisites

- Install [`composer`](https://getcomposer.org)
- Install Google API client library for PHP by running:

```sh
composer install
```

## Run locally

you can run locally using PHP's built-in web server:

```sh
cd php-docs-samples/datastore
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
export GCP_PROJECT_ID=my-project-id
php -S localhost:8080 -t web/
```

Now you can view the app running at [http://localhost:8080](http://localhost:8080)
in your browser.

## Deploy to App Engine

**Prerequisites**

- Install the App Engine PHP SDK.
We recommend you install
[Cloud SDK](https://developers.google.com/cloud/sdk/) rather than
just installing App Engine SDK.

**Deploy with gcloud**

```
$ gcloud preview app deploy app.yaml --set-default --project YOUR_GCP_PROJECT_ID
```

Then access the following URL:
https://{YOUR_GCP_PROJECT_ID}.appspot.com/

### Run for App Engine locally

```
$ dev_appserver.py -A your-project-id .
```

## Contributing changes

* See [CONTRIBUTING.md](../CONTRIBUTING.md)

## Licensing

* See [LICENSE](../LICENSE)


10 changes: 10 additions & 0 deletions datastore/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
runtime: php55
api_version: 1
threadsafe: true

handlers:
- url: /.*
script: web/index.php

env_variables:
GCP_PROJECT_ID: "YOUR_GCP_PROJECT_ID"
19 changes: 19 additions & 0 deletions datastore/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"autoload": {
"psr-4": {
"Google\\Cloud\\Samples\\Datastore\\": "src"
}
},
"require": {
"php": ">=5.4",
"silex/silex": "~1.3",
"twig/twig": "~1.8|~2.0",
"symfony/twig-bridge": "~2.7|3.0.*",
"google/apiclient": "~2.0@RC"
},
"require-dev": {
"symfony/dom-crawler": "~2.0",
"symfony/css-selector": "~2.0",
"symfony/browser-kit": "~2.7"
}
}
Loading