pulkitjalan/google-apiclient
Composer 安装命令:
composer require pulkitjalan/google-apiclient
包简介
Google api php client wrapper with Cloud Platform and Laravel support
README 文档
README
Google api php client wrapper with Cloud Platform and Laravel support
Requirements
- PHP >=8.0
Installation
Install via composer
composer require pulkitjalan/google-apiclient
Laravel
To use in laravel add the following to the providers array in your config/app.php
PulkitJalan\Google\GoogleServiceProvider::class
Next add the following to the aliases array in your config/app.php
'Google' => PulkitJalan\Google\Facades\Google::class
Finally run php artisan vendor:publish --provider="PulkitJalan\Google\GoogleServiceProvider" --tag="config" to publish the config file.
Using an older version of PHP / Laravel?
If you are on a PHP version below 8.0 or a Laravel version below 10.0, use an older version of this package.
Usage
The Client class takes an array as the first parameter, see example of config file below:
return [ /* |---------------------------------------------------------------------------- | Google application name |---------------------------------------------------------------------------- */ 'application_name' => '', /* |---------------------------------------------------------------------------- | Google OAuth 2.0 access |---------------------------------------------------------------------------- | | Keys for OAuth 2.0 access, see the API console at | https://developers.google.com/console | */ 'client_id' => '', 'client_secret' => '', 'redirect_uri' => '', 'scopes' => [], 'access_type' => 'online', 'prompt' => 'auto', /* |---------------------------------------------------------------------------- | Google developer key |---------------------------------------------------------------------------- | | Simple API access key, also from the API console. Ensure you get | a Server key, and not a Browser key. | */ 'developer_key' => '', /* |---------------------------------------------------------------------------- | Google service account |---------------------------------------------------------------------------- | | Set the credentials JSON's location to use assert credentials, otherwise | app engine or compute engine will be used. | */ 'service' => [ /* | Enable service account auth or not. */ 'enabled' => false, /* | Path to service account json file */ 'file' => '', ], /* |---------------------------------------------------------------------------- | Additional config for the Google Client |---------------------------------------------------------------------------- | | Set any additional config variables supported by the Google Client | Details can be found here: | https://github.com/google/google-api-php-client/blob/master/src/Google/Client.php | | NOTE: If client id is specified here, it will get over written by the one above. | */ 'config' => [], ];
To use Google Cloud Platform services, enter the location to the service account JSON file (not the JSON string itself). To use App Engine or Computer Engine, leave it blank.
From Google's upgrading document:
Note: P12s are deprecated in favor of service account JSON, which can be generated in the Credentials section of Google Developer Console.
Get Google\Client
$client = new PulkitJalan\Google\Client($config); $googleClient = $client->getClient();
Laravel Example:
$googleClient = Google::getClient();
Get a service
$client = new PulkitJalan\Google\Client($config); // returns instance of \Google\Service\Storage $storage = $client->make('storage'); // list buckets example $storage->buckets->listBuckets('project id'); // get object example $storage->objects->get('bucket', 'object');
Laravel Example:
// returns instance of \Google\Service\Storage $storage = Google::make('storage'); // or $storage = Google::make(\Google\Service\Storage::class); // list buckets example $storage->buckets->listBuckets('project id'); // get object example $storage->objects->get('bucket', 'object');
Have a look at google/google-api-php-client-services to get a full list of the supported Google Services.
pulkitjalan/google-apiclient 适用场景与选型建议
pulkitjalan/google-apiclient 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.02M 次下载、GitHub Stars 达 258, 最近一次更新时间为 2015 年 01 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「google」 「laravel」 「cloud platform」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pulkitjalan/google-apiclient 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pulkitjalan/google-apiclient 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pulkitjalan/google-apiclient 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
Small library to access Microsoft Windows Azure Blob Storage with a Service or a StreamWrapper.
UCloud Resource (Cloud) Storage SDK for PHP
The flysystem adapter for yandex disk rest api.
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
非官方云小票机SDK,支持飞鹅云,芯烨云,易联云,快递100,映美云,中午云,佳博云,优声云,365智能云打印等
统计信息
- 总下载量: 3.02M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 264
- 点击次数: 14
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-25