shopforward/google-cloud
Composer 安装命令:
composer require shopforward/google-cloud
包简介
Google Cloud Client Library
关键字:
README 文档
README
Idiomatic PHP client for Google Cloud Platform services.
CI Status
| PHP Version | Status |
|---|---|
View the list of supported APIs and Services.
If you need support for other Google APIs, please check out the Google APIs Client Library for PHP.
Quick Start
We recommend installing individual component packages. A list of available packages can be found on Packagist.
For example:
$ composer require google/cloud-storage $ composer require google/cloud-bigquery $ composer require google/cloud-datastore
You can then include the autoloader and create your client:
require 'vendor/autoload.php'; use Google\Cloud\Storage\StorageClient; $storage = new StorageClient(); $bucket = $storage->bucket('my_bucket'); // Upload a file to the bucket. $bucket->upload( fopen('/data/file.txt', 'r') ); // Download and store an object from the bucket locally. $object = $bucket->object('file_backup.txt'); $object->downloadToFile('/data/file_backup.txt');
Authentication
Authentication is handled by the client library automatically. You just need to provide the authentication details when creating a client. Generally, authentication is accomplished using a Service Account. For more information on obtaining Service Account credentials, see our Authentication Guide.
Once you've obtained your credentials file, it may be used to create an authenticated client.
require 'vendor/autoload.php'; use Google\Cloud\Storage\StorageClient; // Authenticate using a keyfile path $cloud = new StorageClient([ 'keyFilePath' => 'path/to/keyfile.json' ]); // Authenticate using keyfile data $cloud = new StorageClient([ 'keyFile' => json_decode(file_get_contents('/path/to/keyfile.json'), true) ]);
If you do not wish to embed your authentication information in your application code, you may also make use of Application Default Credentials.
require 'vendor/autoload.php'; use Google\Cloud\Storage\StorageClient; putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/keyfile.json'); $cloud = new StorageClient();
The GOOGLE_APPLICATION_CREDENTIALS environment variable may be set in your server configuration.
gRPC and Protobuf
Many clients in Google Cloud PHP offer support for gRPC, either as an option or a requirement. gRPC is a high-performance RPC framework created by Google. To use gRPC in PHP, you must install the gRPC PHP extension on your server. While not required, it is also recommended that you install the protobuf extension whenever using gRPC in production.
$ pecl install grpc
$ pecl install protobuf
Caching Access Tokens
By default the library will use a simple in-memory caching implementation, however it is possible to override this behavior by passing a PSR-6 caching implementation in to the desired client.
The following example takes advantage of Symfony's Cache Component.
require 'vendor/autoload.php'; use Google\Cloud\Storage\StorageClient; use Symfony\Component\Cache\Adapter\ArrayAdapter; // Please take the proper precautions when storing your access tokens in a cache no matter the implementation. $cache = new ArrayAdapter(); $storage = new StorageClient([ 'authCache' => $cache ]);
This library provides a PSR-6 implementation with the SystemV shared memory at Google\Auth\Cache\SysVCacheItemPool. This implementation is only available on *nix machines, but it's the one of the fastest implementations and you can share the cache among multiple processes. The following example shows how to use it.
require __DIR__ . '/vendor/autoload.php'; use Google\Cloud\Spanner\SpannerClient; use Google\Auth\Cache\SysVCacheItemPool; $cache = new SysVCacheItemPool(); $spanner = new SpannerClient([ 'authCache' => $cache ]);
PHP Versions Supported
All client libraries support PHP 8.0 and above.
Versioning
This library follows Semantic Versioning.
Please note it is currently under active development. Any release versioned 0.x.y is subject to backwards incompatible changes at any time.
GA: Libraries defined at a GA quality level are stable, and will not introduce backwards-incompatible changes in any minor or patch releases. We will address issues and requests with the highest priority. Please note, for any components which include generated clients the GA guarantee will only apply to clients which interact with stable services. For example, in a component which hosts V1 and V1beta1 generated clients, the GA guarantee will only apply to the V1 client as the service it interacts with is considered stable.
Beta: Libraries defined at a Beta quality level are expected to be mostly stable and we're working towards their release candidate. We will address issues and requests with a higher priority.
Contributing
Contributions to this library are always welcome and highly encouraged.
See CONTRIBUTING for more information on how to get started.
This repository is not an official support channel. If you have support questions, file a support request through the normal Google support channels, or post questions on a forum such as StackOverflow.
License
Apache 2.0 - See LICENSE for more information.
shopforward/google-cloud 适用场景与选型建议
shopforward/google-cloud 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 08 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「translation」 「storage」 「google」 「language」 「cloud」 「Tasks」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shopforward/google-cloud 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shopforward/google-cloud 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shopforward/google-cloud 相关的其它包
同方向 / 同关键字的高下载量 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.
A custom URL rule class for Yii 2 which allows to create translated URL rules
A Laravel Eloquent model trait for translatable resource
Bureaux A Partager Edit - Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Symfony localise.biz library
统计信息
- 总下载量: 46
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 40
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2024-08-19