schulzefelix / laravel-bigquery
1.7.0
2022-02-26 12:11 UTC
Requires
- php: ^8.0.2
- google/cloud-bigquery: ^1.0
- illuminate/support: ^9.0
- symfony/cache: ^6.0
Requires (Dev)
- mockery/mockery: ^1.4
- orchestra/testbench: ^7.0
- phpunit/phpunit: ^9.4
README
使用此包,您可以轻松地与 Google BigQuery API 进行交互。
安装
此包可以通过 Composer 安装。
composer require schulzefelix/laravel-bigquery
可选地,您可以使用以下命令发布此包的配置文件
php artisan vendor:publish --provider="SchulzeFelix\BigQuery\BigQueryServiceProvider"
以下配置文件将发布到 config/bigquery.php
return [ /* |-------------------------------------------------------------------------- | Application Credentials |-------------------------------------------------------------------------- | | Path to the Service Account Credentials JSON File | | https://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.35.0/guides/authentication | */ 'application_credentials' => env('GOOGLE_CLOUD_APPLICATION_CREDENTIALS'), /* | OPTIONAL: | Use keyFile to use a json config from the current environment. | For example secrets in laravel vapor | | https://vapor-docs.laravel.net.cn/1.0/projects/environments.html#secrets */ //'keyFile' => json_decode(trim(env('GOOGLE_CLOUD_APPLICATION_CREDENTIALS')), true), /* |-------------------------------------------------------------------------- | Project ID |-------------------------------------------------------------------------- | | The Project Name is a user-friendly name, | while the Project ID is required by the Google Cloud client libraries to authenticate API requests. | */ 'project_id' => env('GOOGLE_CLOUD_PROJECT_ID'), /* |-------------------------------------------------------------------------- | Client Auth Cache Store |-------------------------------------------------------------------------- | | This option controls the auth cache connection that gets used. | | Supported: "apc", "array", "database", "file", "memcached", "redis" | */ 'auth_cache_store' => 'file', /* |-------------------------------------------------------------------------- | Client Options |-------------------------------------------------------------------------- | | Here you may configure additional parameters that | the underlying BigQueryClient will use. | | Optional parameters: "authCacheOptions", "authHttpHandler", "httpHandler", "retries", "scopes", "returnInt64AsObject" */ 'client_options' => [ 'retries' => 3, // Default ], /* |-------------------------------------------------------------------------- | Dataset location |-------------------------------------------------------------------------- | | Specify the dataset location. | | Supported values can be found at https://cloud.google.com/bigquery/docs/locations | */ 'location' => '', ];
用法
此包仅初始化 BigQuery 连接,您可以使用类似于 Google API 中的任何方法。您可以使用提供的 Facade 或从 IoC 容器中检索它。
BigQuery::apiMethod(); app('bigquery')->apiMethod();
以下是创建数据集和检查表是否存在的基本示例
创建数据集
$dataset = BigQuery::createDataset('myNewDataSet');
检查表是否存在
BigQuery::dataset(myNewDataSet)->table('aTable')->exists());
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG
测试
$ vendor/bin/phpunit
贡献
有关详细信息,请参阅 CONTRIBUTING 和 CONDUCT
安全
如果您发现任何安全相关的问题,请通过电子邮件 github@schulze.co 而不是使用问题跟踪器。
鸣谢
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件