phpexperts/gcloud-auth
Composer 安装命令:
composer require phpexperts/gcloud-auth
包简介
A drop-dead simple way to authenticate APIs with Google Cloud without needing the gcloud-api dependency.
关键字:
README 文档
README
GCloud Auth is a PHP Experts, Inc., Project for authenticating with Google Cloud API without needing the huge gcloud binary.
As of April 2025, the google-cloud-cli weighs in at around 150 MB, not counting dependencies,
and over 550 MB counting dependencies, on modern Linux systems.
Using the google/apiclient composer package itself weighs in at 141 MB.
This project, by comparison, weighs in around 10 KB (or 15,000x smaller).
It provides everything you need to retrieve an OAuth2 token for authenticating with Google Cloud API services. It autogenerates the JWT token necessary for this, using ext-openssl.
It includes a drop-in phpexperts/rest-speaker GoogleAuth driver, but it can
also be used standalone by any PHP project.
Installation
Via Composer
composer require phpexperts/gcloud-auth
Usage
For use with phpexperts/rest-speaker:
use PHPExperts\GoogleCloudAuth\GoogleCloudAuth; use PHPExperts\RESTSpeaker\RESTSpeaker; $api = new RESTSpeaker(new GoogleCloudAuth('relative/path/to/services.json'));
For use with any other PHP project:
use PHPExperts\GoogleCloudAuth\GoogleCloudAuth; $gcloudAuth = new GoogleCloudAuth('relative/path/to/services.json'); // Returns the raw Oauth2Token as a string. $gcloudOauth2Token = $gcloudAuth->obtainGCloudOauthToken(); $url = "https://storage.googleapis.com/storage/v1/b?project=$projectId"; $http = new \GuzzleHttp\Client([ 'headers' => [ 'Content-Type' => 'application/json', 'Authorization' => "Bearer $gcloudOauth2Token", ] ]); $response = $http->get($url);
Use cases
✔ Can authenticate with GCloud ✔ Handles invalid service account path ✔ Handles invalid service account data ✔ Handles error responses from Google Cloud ✔ Can override time for testing ✔ Will cache the OAuth2 Token until expiration ✔ Can synthesize speech using the GCloud API
Testing
phpunit --testdox
Contributors
Theodore R. Smith theodore@phpexperts.pro
GPG Fingerprint: 4BF8 2613 1C34 87AC D28F 2AD8 EB24 A91D D612 5690
CEO: PHP Experts, Inc.
License
MIT license. Please see the license file for more information.
phpexperts/gcloud-auth 适用场景与选型建议
phpexperts/gcloud-auth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「google cloud」 「gcloud」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phpexperts/gcloud-auth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpexperts/gcloud-auth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phpexperts/gcloud-auth 相关的其它包
同方向 / 同关键字的高下载量 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智能云打印等
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-10