shopforward / google-cloud
Google Cloud 客户端库
Requires
- php: ^8.0
- google/auth: ^1.34
- google/gax: ^1.34.0
- guzzlehttp/guzzle: ^7.4.5
- guzzlehttp/psr7: ^2.6
- monolog/monolog: ^2.9||^3.0
- psr/http-message: ^1.0|^2.0
- ramsey/uuid: ^4.0
- rize/uri-template: ~0.3
Requires (Dev)
- dg/bypass-finals: ^1.7
- erusev/parsedown: ^1.6
- flix-tech/avro-php: ^5.0.0
- google/cloud-tools: ^0.14.0
- kreait/firebase-php: ^6.9
- opis/closure: ^3.0
- phpdocumentor/reflection: ^5.0
- phpseclib/phpseclib: ^3.0
- phpspec/prophecy-phpunit: ^2.1
- phpunit/phpunit: ^9.6
- psr/log: ^2.0||^3.0
Suggests
- opis/closure: May be used to serialize closures to process jobs in the batch daemon. Please require version ^3.
- phpseclib/phpseclib: May be used in place of OpenSSL for creating signed Cloud Storage URLs. Please require version ^2.
Replaces
- google/access-context-manager: 1.0.0
- google/analytics-admin: 0.24.0
- google/analytics-data: 0.18.0
- google/apps-chat: 0.3.0
- google/apps-events-subscriptions: 0.1.3
- google/apps-meet: 0.2.3
- google/cloud-access-approval: 2.0.0-RC1
- google/cloud-advisorynotifications: 1.0.0
- google/cloud-ai-platform: 1.3.0
- google/cloud-alloydb: 1.0.0
- google/cloud-api-gateway: 1.3.5
- google/cloud-api-keys: 1.0.0
- google/cloud-apigee-connect: 2.0.0-RC1
- google/cloud-apigee-registry: 1.0.0
- google/cloud-appengine-admin: 1.3.5
- google/cloud-apphub: 0.1.3
- google/cloud-artifact-registry: 1.0.0
- google/cloud-asset: 1.16.4
- google/cloud-assured-workloads: 1.0.0
- google/cloud-automl: 1.6.5
- google/cloud-backupdr: 0.2.0
- google/cloud-bare-metal-solution: 1.0.0
- google/cloud-batch: 1.0.1
- google/cloud-beyondcorp-appconnections: 1.0.0
- google/cloud-beyondcorp-appconnectors: 1.0.0
- google/cloud-beyondcorp-appgateways: 1.0.0
- google/cloud-beyondcorp-clientconnectorservices: 1.0.0
- google/cloud-beyondcorp-clientgateways: 1.0.0
- google/cloud-bigquery: 1.30.3
- google/cloud-bigquery-analyticshub: 1.0.0
- google/cloud-bigquery-connection: 1.5.5
- google/cloud-bigquery-data-exchange: 0.4.5
- google/cloud-bigquery-datapolicies: 1.0.0
- google/cloud-bigquery-migration: 1.1.0
- google/cloud-bigquery-reservation: 2.0.0-RC1
- google/cloud-bigquery-storage: 1.10.4
- google/cloud-bigquerydatatransfer: 1.8.5
- google/cloud-bigtable: 2.2.0
- google/cloud-billing: 1.9.8
- google/cloud-billing-budgets: 2.0.0-RC1
- google/cloud-binary-authorization: 1.0.1
- google/cloud-build: 1.0.0
- google/cloud-certificate-manager: 1.0.0
- google/cloud-channel: 1.9.5
- google/cloud-cloudcontrolspartner: 0.1.4
- google/cloud-commerce-consumer-procurement: 1.0.0
- google/cloud-common-protos: 0.6.0
- google/cloud-compute: 1.18.1
- google/cloud-confidentialcomputing: 1.1.0
- google/cloud-config: 1.0.0
- google/cloud-contact-center-insights: 2.0.0-RC1
- google/cloud-container: 1.33.0
- google/cloud-container-analysis: 1.0.1
- google/cloud-core: 1.59.1
- google/cloud-data-catalog: 2.0.0-RC1
- google/cloud-data-fusion: 1.0.0
- google/cloud-datacatalog-lineage: 1.0.0
- google/cloud-dataflow: 0.6.4
- google/cloud-dataform: 0.4.5
- google/cloud-datalabeling: 0.5.5
- google/cloud-dataplex: 1.0.0
- google/cloud-dataproc: 3.14.0
- google/cloud-dataproc-metastore: 1.0.0
- google/cloud-datastore: 1.29.2
- google/cloud-datastore-admin: 1.0.0
- google/cloud-datastream: 1.5.5
- google/cloud-debugger: 1.8.8
- google/cloud-deploy: 1.1.1
- google/cloud-developerconnect: 0.1.1
- google/cloud-dialogflow: 1.13.0
- google/cloud-dialogflow-cx: 0.4.0
- google/cloud-discoveryengine: 1.0.0
- google/cloud-dlp: 1.18.0
- google/cloud-dms: 2.0.0-RC1
- google/cloud-document-ai: 1.14.0
- google/cloud-domains: 1.0.0
- google/cloud-edgenetwork: 1.1.0
- google/cloud-error-reporting: 0.22.7
- google/cloud-essential-contacts: 1.0.0
- google/cloud-eventarc: 2.0.0-RC1
- google/cloud-eventarc-publishing: 1.0.0
- google/cloud-filestore: 2.0.0-RC1
- google/cloud-firestore: 1.45.0
- google/cloud-functions: 1.7.0
- google/cloud-game-servers: 1.2.6
- google/cloud-gke-backup: 1.0.0
- google/cloud-gke-connect-gateway: 0.4.4
- google/cloud-gke-hub: 1.0.0
- google/cloud-gke-multi-cloud: 1.0.0
- google/cloud-gsuite-addons: 1.0.0
- google/cloud-iam: 1.0.0
- google/cloud-iam-credentials: 1.2.5
- google/cloud-iap: 1.4.5
- google/cloud-ids: 1.0.0
- google/cloud-iot: 1.7.5
- google/cloud-kms: 1.23.0
- google/cloud-kms-inventory: 1.0.0
- google/cloud-language: 0.33.0
- google/cloud-life-sciences: 0.6.6
- google/cloud-logging: 1.30.3
- google/cloud-managed-identities: 2.0.0-RC1
- google/cloud-managedkafka: 0.1.1
- google/cloud-media-translation: 0.4.4
- google/cloud-memcache: 1.3.5
- google/cloud-migrationcenter: 1.0.0
- google/cloud-monitoring: 1.11.0
- google/cloud-netapp: 1.0.1
- google/cloud-network-connectivity: 2.0.0-RC1
- google/cloud-network-management: 2.0.0-RC1
- google/cloud-network-security: 1.0.0
- google/cloud-networkservices: 0.2.0
- google/cloud-notebooks: 1.0.0
- google/cloud-optimization: 1.0.0
- google/cloud-orchestration-airflow: 2.0.0-RC1
- google/cloud-org-policy: 1.0.0
- google/cloud-osconfig: 1.3.5
- google/cloud-oslogin: 2.0.0-RC1
- google/cloud-parallelstore: 0.5.0
- google/cloud-policy-troubleshooter: 2.0.0-RC1
- google/cloud-policysimulator: 1.0.0
- google/cloud-policytroubleshooter-iam: 0.2.6
- google/cloud-private-catalog: 0.4.4
- google/cloud-privilegedaccessmanager: 0.1.0
- google/cloud-profiler: 1.4.3
- google/cloud-pubsub: 2.5.0
- google/cloud-quotas: 1.0.0
- google/cloud-rapidmigrationassessment: 1.0.0
- google/cloud-recaptcha-enterprise: 1.13.0
- google/cloud-recommendations-ai: 0.7.5
- google/cloud-recommender: 2.0.0-RC1
- google/cloud-redis: 1.9.5
- google/cloud-redis-cluster: 0.3.0
- google/cloud-resource-manager: 1.0.0
- google/cloud-resource-settings: 2.0.0-RC1
- google/cloud-retail: 1.7.0
- google/cloud-run: 1.1.0
- google/cloud-scheduler: 1.10.5
- google/cloud-secret-manager: 1.15.2
- google/cloud-securesourcemanager: 1.1.0
- google/cloud-security-center: 1.32.0
- google/cloud-security-private-ca: 1.7.3
- google/cloud-security-public-ca: 1.0.0
- google/cloud-securitycentermanagement: 1.0.0
- google/cloud-service-control: 1.4.4
- google/cloud-service-directory: 1.3.6
- google/cloud-service-management: 1.3.5
- google/cloud-service-usage: 1.3.4
- google/cloud-servicehealth: 0.1.6
- google/cloud-shell: 2.0.0-RC1
- google/cloud-spanner: 1.83.0
- google/cloud-speech: 1.19.0
- google/cloud-sql-admin: 1.1.0
- google/cloud-storage: 1.42.1
- google/cloud-storage-control: 1.0.0
- google/cloud-storage-transfer: 1.4.5
- google/cloud-storageinsights: 1.0.0
- google/cloud-support: 1.0.0
- google/cloud-talent: 1.3.5
- google/cloud-tasks: 1.14.6
- google/cloud-telcoautomation: 1.0.0
- google/cloud-text-to-speech: 1.8.5
- google/cloud-tpu: 1.4.5
- google/cloud-trace: 1.8.6
- google/cloud-translate: 1.18.0
- google/cloud-video-live-stream: 1.1.0
- google/cloud-video-stitcher: 1.0.0
- google/cloud-video-transcoder: 1.0.0
- google/cloud-videointelligence: 1.15.5
- google/cloud-vision: 1.9.4
- google/cloud-vm-migration: 1.0.0
- google/cloud-vmware-engine: 1.1.0
- google/cloud-vpc-access: 2.0.0-RC1
- google/cloud-web-risk: 1.5.5
- google/cloud-web-security-scanner: 1.0.0
- google/cloud-workflows: 1.0.0
- google/common-protos: 4.8.1
- google/geo-common-protos: 0.2.0
- google/grafeas: 1.1.0
- google/longrunning: 0.4.3
- google/maps-fleetengine: 0.1.2
- google/maps-fleetengine-delivery: 0.1.3
- google/maps-routeoptimization: 0.1.0
- google/shopping-common-protos: 0.4.0
- google/shopping-css: 0.2.8
- google/shopping-merchant-accounts: 0.1.0
- google/shopping-merchant-conversions: 0.1.2
- google/shopping-merchant-datasources: 0.1.0
- google/shopping-merchant-inventories: 0.5.0
- google/shopping-merchant-lfp: 0.1.0
- google/shopping-merchant-notifications: 0.1.0
- google/shopping-merchant-products: 0.1.0
- google/shopping-merchant-promotions: 0.1.0
- google/shopping-merchant-quota: 0.1.3
- google/shopping-merchant-reports: 0.8.1
This package is not auto-updated.
Last update: 2024-09-17 07:00:57 UTC
README
针对 Google Cloud Platform 服务的 PHP 风格客户端。
CI 状态
查看支持的 API 和服务的列表 这里。
如果您需要其他 Google API 的支持,请查看 Google APIs 客户端库 for PHP。
快速入门
我们建议安装单个组件包。可在 Packagist 上找到可用包的列表。
例如
$ composer require google/cloud-storage $ composer require google/cloud-bigquery $ composer require google/cloud-datastore
您随后可以包含自动加载器并创建客户端
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');
身份验证
身份验证由客户端库自动处理。您只需在创建客户端时提供身份验证详情。通常,身份验证是通过服务帐户完成的。有关获取服务帐户凭证的更多信息,请参阅我们的 身份验证指南。
一旦您获得凭证文件,即可用于创建经过身份验证的客户端。
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) ]);
如果您不希望在应用程序代码中嵌入身份验证信息,您还可以使用 应用程序默认凭证。
require 'vendor/autoload.php'; use Google\Cloud\Storage\StorageClient; putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/keyfile.json'); $cloud = new StorageClient();
您可以在服务器配置中设置 GOOGLE_APPLICATION_CREDENTIALS
环境变量。
gRPC 和 Protobuf
Google Cloud PHP 中的许多客户端提供对 gRPC 的支持,无论是作为选项还是必需项。gRPC 是 Google 创建的高性能 RPC 框架。要在 PHP 中使用 gRPC,您必须在您的服务器上安装 gRPC PHP 扩展。虽然不是必需的,但建议在生产环境中使用 gRPC 时也安装 protobuf 扩展。
$ pecl install grpc
$ pecl install protobuf
缓存访问令牌
默认情况下,库将使用简单的内存缓存实现,但是您可以通过向所需客户端传递 PSR-6 缓存实现来覆盖此行为。
以下示例利用了 Symfony 的缓存组件。
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 ]);
此库提供具有 Google\Auth\Cache\SysVCacheItemPool
的 SystemV 共享内存的 PSR-6 实现。此实现仅在 *nix 机器上可用,但它是最快的实现之一,并且您可以在多个进程之间共享缓存。以下示例说明了如何使用它。
require __DIR__ . '/vendor/autoload.php'; use Google\Cloud\Spanner\SpannerClient; use Google\Auth\Cache\SysVCacheItemPool; $cache = new SysVCacheItemPool(); $spanner = new SpannerClient([ 'authCache' => $cache ]);
支持的 PHP 版本
所有客户端库都支持 PHP 8.0 及以上版本。
版本控制
此库遵循 语义版本控制。
请注意,它目前正在积极开发中。任何版本号为 0.x.y 的发布版本都可能随时发生向后不兼容的更改。
GA:在GA质量级别定义的库是稳定的,不会在任何一个次要版本或补丁版本中引入不向后兼容的更改。我们将以最高优先级解决问题和请求。请注意,对于包含生成客户端的任何组件,GA保证仅适用于与稳定服务交互的客户端。例如,在一个托管V1和V1beta1生成客户端的组件中,GA保证仅适用于V1客户端,因为它与之交互的服务被视为稳定。
Beta:在Beta质量级别定义的库预计将是大多数稳定的,我们正在努力使其成为发布候选版本。我们将以更高的优先级解决问题和请求。
贡献
对这个库的贡献总是受欢迎并被高度鼓励。
有关如何开始的更多信息,请参阅CONTRIBUTING。
此存储库不是官方支持渠道。如果您有支持问题,请通过正常的Google支持渠道提交支持请求,或在如StackOverflow之类的论坛上发帖提问。
许可证
Apache 2.0 - 更多信息请参阅LICENSE。