wethinkright / google-cloud-silex
Google Cloud PHP 的 Silex 服务提供者
v1.0
2016-11-13 21:55 UTC
Requires
- google/cloud: *
- silex/silex: ~2
Requires (Dev)
- phpunit/phpunit: ^5.6
- squizlabs/php_codesniffer: 2.*
This package is not auto-updated.
Last update: 2024-09-14 20:26:41 UTC
README
此包可以使将 Google Cloud PHP 集成到您的 Silex 应用程序变得快捷且简单。
安装
$ composer require wethinkright/google-cloud-silex
使用方法
要了解 ServiceProviders 的工作原理以及如何在您的应用程序中加载它们,请参阅 Silex 文档。
<?php use Silex\Application; use WeThinkRight\GoogleCloudSilex\GoogleCloudProvider; $app = new Application; $app->register(new GoogleCloudProvider(), [ 'cloud.config' => [ 'keyFilePath' => '/path/to/service/account/credentials.json' ] ]); $pubsub = $app['cloud']->pubsub();
服务
为方便起见,为 Google Cloud PHP 的每个 API 提供服务。
$bigquery = $app['cloud.bigquery']; $datastore = $app['cloud.datastore']; $logging = $app['cloud.logging']; $language = $app['cloud.language']; $pubsub = $app['cloud.pubsub']; $speech = $app['cloud.speech']; $storage = $app['cloud.storage']; $translate = $app['cloud.translate']; $vision = $app['cloud.vision'];
配置
要了解如何配置 Google Cloud PHP,请参阅 Google\Cloud\ServiceBuilder::__construct()
文档。
- 配置数组可以在注册服务提供者时提供
<?php use Silex\Application; use WeThinkRight\GoogleCloudSilex\GoogleCloudProvider; $app = new Application; $app->register(new GoogleCloudProvider(), [ 'cloud.config' => [ 'keyFilePath' => '/path/to/service/account/credentials.json' ] ]);
- 或者,它可以在注册服务提供者之前分配
<?php use Silex\Application; use WeThinkRight\GoogleCloudSilex\GoogleCloudProvider; $app = new Application; $app['cloud.config'] = [ 'keyFilePath' => '/path/to/service/account/credentials.json' ]; $app->register(new GoogleCloudProvider());
许可证
此包根据 Apache 2.0 软件许可证授权。有关更多信息,请参阅 LICENSE。