Skip to content

Commit d031daa

Browse files
authored
Refactor BigQuery samples (GoogleCloudPlatform#705)
1 parent 1bc350d commit d031daa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1905
-3670
lines changed

bigquery/api/README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Description
44

5-
This simple command-line application demonstrates how to invoke Google BigQuery from PHP.
5+
All code in the `snippets` directory demonstrate how to invoke Google BigQuery from PHP.
66

77
## Build and Run
88
1. **Enable APIs** - [Enable the BigQuery API](https://console.cloud.google.com/flows/enableapi?apiid=bigquery)
@@ -12,27 +12,23 @@ This simple command-line application demonstrates how to invoke Google BigQuery
1212
select "Create". Once downloaded, set the environment variable `GOOGLE_APPLICATION_CREDENTIALS`
1313
to the path of the JSON key that was downloaded.
1414
3. **Clone the repo** and cd into this directory
15-
1615
```sh
1716
$ git clone https://github.com/GoogleCloudPlatform/php-docs-samples
1817
$ cd php-docs-samples/bigquery/api
19-
```
18+
```
19+
2020
4. **Install dependencies** via [Composer](http://getcomposer.org/doc/00-intro.md).
2121
Run `php composer.phar install` (if composer is installed locally) or `composer install`
2222
(if composer is installed globally).
23-
5. Run `php bigquery.php`. The following commands are available:
24-
23+
5. Run `php snippets/SNIPPET_NAME.php`. The usage will print for each if no arguments
24+
are provided:
2525
```sh
26-
browse-table Browse a BigQuery table
27-
datasets List BigQuery datasets
28-
export Export data from a BigQuery table into a Cloud Storage bucket
29-
import Import data into a BigQuery table
30-
projects List BigQuery projects
31-
query Run a BigQuery query
32-
schema Create or delete a table schema in BigQuery
33-
tables List BigQuery tables
34-
6. Run `php bigquery.php COMMAND --help` to print information about the usage of each command.
35-
```
26+
$ php snippets/create_dataset.php
27+
Usage: php snippets/create_dataset.php PROJECT_ID DATASET_ID
28+
29+
$ php snippets/create_dataset.php your-project-id test_dataset_123
30+
Created dataset test_dataset_123
31+
```
3632

3733
## Contributing changes
3834

bigquery/api/bigquery.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

bigquery/api/composer.json

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,10 @@
11
{
22
"require": {
3-
"google/cloud-bigquery": "^1.0",
4-
"google/cloud-storage": "^1.2",
5-
"symfony/console": "^3.0"
3+
"google/cloud-bigquery": "^1.4",
4+
"google/cloud-storage": "^1.7"
65
},
76
"require-dev": {
8-
"guzzlehttp/guzzle": "^6.3",
9-
"google/cloud-tools": "^0.6",
10-
"phpunit/phpunit": "~4.8"
11-
},
12-
"autoload": {
13-
"psr-4": {
14-
"Google\\Cloud\\Samples\\BigQuery\\": "src/"
15-
},
16-
"files": [
17-
"src/functions/browse_table.php",
18-
"src/functions/copy_table.php",
19-
"src/functions/create_dataset.php",
20-
"src/functions/create_table.php",
21-
"src/functions/delete_table.php",
22-
"src/functions/extract_table.php",
23-
"src/functions/import_from_file.php",
24-
"src/functions/import_from_storage.php",
25-
"src/functions/insert_sql.php",
26-
"src/functions/list_datasets.php",
27-
"src/functions/list_tables.php",
28-
"src/functions/run_query.php",
29-
"src/functions/run_query_as_job.php",
30-
"src/functions/stream_row.php"
31-
]
7+
"google/cloud-tools": "^0.8",
8+
"phpunit/phpunit": "~5"
329
}
3310
}

0 commit comments

Comments
 (0)