hankz/laravel-google-bigquery

v1.0.0 2024-05-09 02:44 UTC

This package is auto-updated.

Last update: 2024-09-09 03:34:26 UTC


README

Latest Version Software License Build Status Quality Score StyleCI Latest Version on Packagist Total Downloads

提示

此包是从schulzefelix/laravel-bigquery分叉而来,并增加了对最新版本的Laravel和PHP的支持。如果您想要使用的版本在原始存储库中已经得到支持,建议您使用原始版本。

使用此包,您可以轻松地与Google BigQuery API交互。

安装

此包可以通过Composer安装。

composer require hankz/laravel-google-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相同的方法。您可以使用提供的门面或从IoC容器中检索它。

BigQuery::apiMethod();

app('bigquery')->apiMethod();

以下有两个基本示例,用于创建数据集和检查表的存在性

创建数据集

$dataset = BigQuery::createDataset('myNewDataSet');

检查表的存在性

BigQuery::dataset(myNewDataSet)->table('aTable')->exists());

变更日志

有关最近更改的更多信息,请参阅CHANGELOG

测试

$ vendor/bin/phpunit

贡献

有关详细信息,请参阅CONTRIBUTINGCONDUCT

安全

如果您发现任何安全相关的问题,请通过电子邮件github@schulze.co而不是使用问题跟踪器。

鸣谢

许可

MIT许可(MIT)。有关更多信息,请参阅许可文件