Skip to content

Commit

Permalink
Added support for Google's ADC.
Browse files Browse the repository at this point in the history
  • Loading branch information
Medalink committed Apr 19, 2018
1 parent 0648e31 commit c894eaf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Added
- Added nullable/required field modes.
- Added support for Google's ADC.

### Changed
- Fix company name typo.
Expand Down
39 changes: 19 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,42 @@ Via Composer
$ composer require prologuetech/big
```

## Configuration

By default we use the following global config options with BigQuery.

```php
$this->options = [
'useLegacySql' => false,
'useQueryCache' => false,
];
```

## Setup

Publish our config file into your application:

``` bash
php artisan vendor:publish --provider="Prologuetech\Big\BigServiceProvider"
```

Set our required environment variables ```BIG_AUTH_FILE``` and ```BIG_PROJECT_ID```:

```.env:```
``` php
BIG_PROJECT_ID=my-project-0000000
BIG_AUTH_FILE=/home/vagrant/app/storage/my-auth-0000.json
```
You should have a `config/prologue-big.php` file to configure defaults.

Add our big service provider to your application providers:
### Laravel 5.4.x
Older versions of Laravel require you to add our big service provider to your application providers array in `config/app.php`:

``` php
Prologuetech\Big\BigServiceProvider::class,
```

You now have access to a familiar laravel experience, enjoy!

## Google Authentication
The Google SDK supports Application Default Credentials (ADC) and thus this package does as well. You may leave your `auth_file` field inside of your config file `null` to use ADC.

For more information see the [adc docs](https://cloud.google.com/docs/authentication/production#auth-cloud-implicit-php).

## How to use

### Configuration

By default we use the following global config options with BigQuery.

```php
$this->options = [
'useLegacySql' => false,
'useQueryCache' => false,
];
```

### Tables

When creating tables in BQ we automatically flip a Eloquent model schema for you. Let's cover an example of archiving data
Expand Down
2 changes: 1 addition & 1 deletion config/prologue-big.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

return [
'big' => [
'auth_file' => env('BIG_AUTH_FILE'),
'auth_file' => env('BIG_AUTH_FILE', null),
'project_id' => env('BIG_PROJECT_ID'),
'default_dataset' => env('BIG_DEFAULT_DATASET'),
],
Expand Down
15 changes: 11 additions & 4 deletions src/Big.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,18 @@ public function __construct()
'useQueryCache' => false,
];

// Setup google service with credentials
$googleService = new ServiceBuilder([
'keyFilePath' => config('prologue-big.big.auth_file'),
// Build our Google config options
$config = [
'projectId' => config('prologue-big.big.project_id'),
]);
];

// Allow Google's default application credentials if developer chooses
if (!is_null(config('prologue-big.big.auth_file'))) {
$config['keyFilePath'] = config('prologue-big.big.auth_file');
}

// Setup google service with credentials
$googleService = new ServiceBuilder($config);

// Set a default dataset
$this->defaultDataset = config('prologue-big.big.default_dataset');
Expand Down

0 comments on commit c894eaf

Please sign in to comment.