|
5 | 5 | This simple command-line application demonstrates how to invoke Google BigQuery from PHP. |
6 | 6 |
|
7 | 7 | ## Build and Run |
8 | | -1. In the [Google Developers Console](https://console.developers.google.com/), |
9 | | - create a new project or choose an existing project. |
10 | | -2. In the [Google Developers Console](https://console.developers.google.com/), |
11 | | - click **APIs & auth**, then click APIs. Wait for a list of APIs to |
12 | | - appear, then click BigQuery. If BigQuery is not already enabled, |
13 | | - click the Enable API button. |
14 | | -3. In the [Google Developers Console](https://console.developers.google.com/), |
15 | | - under **APIs & auth**, click Credentials. Click the button to "Generate |
16 | | - a new JSON key." Set the environment variable |
17 | | - `GOOGLE_APPLICATION_CREDENTIALS` to the path of the JSON key that was |
18 | | - downloaded. |
19 | | -3. Clone this repo with |
| 8 | +1. **Enable APIs** - [Enable the BigQuery API](https://console.cloud.google.com/flows/enableapi?apiid=bigquery) |
| 9 | + and create a new project or select an existing project. |
| 10 | +2. **Download The Credentials** - Click "Go to credentials" after enabling the APIs. Click "New Credentials" |
| 11 | + and select "Service Account Key". Create a new service account, use the JSON key type, and |
| 12 | + select "Create". Once downloaded, set the environment variable `GOOGLE_APPLICATION_CREDENTIALS` |
| 13 | + to the path of the JSON key that was downloaded. |
| 14 | +3. **Clone the repo** and cd into this directory |
20 | 15 |
|
21 | 16 | ```sh |
22 | | - git clone https://github.com/GoogleCloudPlatform/php-docs-samples |
| 17 | + $ git clone https://github.com/GoogleCloudPlatform/php-docs-samples |
| 18 | + $ cd php-docs-samples/bigquery/api |
| 19 | +``` |
| 20 | +4. **Install dependencies** via [Composer](http://getcomposer.org/doc/00-intro.md). |
| 21 | + Run `php composer.phar install` (if composer is installed locally) or `composer install` |
| 22 | + (if composer is installed globally). |
| 23 | +5. Run `php main.php YOUR_PROJECT_NAME` where YOUR_PROJECT_NAME is the |
| 24 | + project associated with the credentials from **step 2**. |
| 25 | + |
| 26 | + ```sh |
| 27 | + $ php main.php my-project-name |
| 28 | + |
| 29 | + Query Results: |
| 30 | + ------------ |
| 31 | + hamlet 5318 |
| 32 | + kinghenryv 5104 |
| 33 | + cymbeline 4875 |
| 34 | + troilusandcressida 4795 |
| 35 | + kinglear 4784 |
| 36 | + kingrichardiii 4713 |
| 37 | + 2kinghenryvi 4683 |
| 38 | + coriolanus 4653 |
| 39 | + 2kinghenryiv 4605 |
| 40 | + antonyandcleopatra 4582 |
23 | 41 | ``` |
24 | | -4. cd into the bigquery directory. |
25 | | -5. Download [Composer](http://getcomposer.org/doc/00-intro.md) or update `composer self-update`. |
26 | | -6. Run `php composer.phar install`. |
27 | | -7. Run `php main.php`. |
28 | 42 |
|
29 | 43 | ## Contributing changes |
30 | 44 |
|
|
0 commit comments