Skip to content
Closed
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
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ before_install:
- php dump_credentials.php

script:
# run bigquery tests
- cd bigquery/api
- composer install
- phpunit mainTest.php
- phpunit utilTest.php
- cd ../..
# run pubsub tests
- cd pubsub
- composer install
- phpunit test
- cd ..
75 changes: 75 additions & 0 deletions pubsub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Google PubSub PHP Sample Application

## Description

Note: The push endpoints don't work with the App Engine's local
devserver. The push notifications will go to an HTTP URL on the App
Engine server even when you run this sample locally. So we recommend
you deploy and run the app on App Engine.
TODO(tmatsuo): Better implementation for devserver.

## 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 Pub/Sub" API under "APIs & auth > APIs."

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

GOOGLE_APPLICATION_CREDENTIALS: the file path to the downloaded JSON file.

## Prerequisites

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

- Install Google API client library for PHP into 'lib' directory by running:

```
$ composer install
```

## Configuration

- Edit config.json
- Replace '{A_UNIQUE_TOKEN}' with an arbitrary secret string of
your choice to protect the endpoint from abuse.

- Replace '{YOUR_PROJECT_ID}' with your project ID
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, @jonparrott and I have been using environment variables

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YOUR_PROJECT_ID definitely needs to be settable from an environment variable, so that forked repos can run travis tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been naming this GOOGLE_PROJECT_ID in our other samples. We probably want to keep it consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


## Deploy the application to App Engine

```
$ gcloud preview app deploy app.yaml --set-default --project YOUR_PROJECT_ID
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe --set-default is now --promote. you may also want to tell people to use --version

```

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

## Run the application locally

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

## Contributing changes

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

## Licensing

* See [LICENSE](../LICENSE)


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

handlers:
- url: /js
static_dir: web/js
- url: /.*
script: web/index.php
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/receive_message handler is redundant

19 changes: 19 additions & 0 deletions pubsub/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"autoload": {
"psr-4": {
"GoogleCloudPlatform\\DocsSamples\\Pubsub\\": "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@dev"
},
"require-dev": {
"symfony/dom-crawler": "~2.0",
"symfony/css-selector": "~2.0",
"symfony/browser-kit": "~2.7"
}
}
Loading