承接 codeinc/cloudrun-auth-http-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

codeinc/cloudrun-auth-http-client

最新稳定版本:v1.4

Composer 安装命令:

composer require codeinc/cloudrun-auth-http-client

包简介

A PSR-7 HTTP client based on Guzzle for services hosted on Google Cloud Platform Cloud Run

README 文档

README

The PHP 8.2+ library is a PSR-7 HTTP client based on Guzzle and the official Google Auth PHP package for services hosted on Google Cloud Platform Cloud Run.

Installation

The recommended way to install the library is through Composer:

composer require codeinc/cloudrun-auth-http-client

Usage

A GCP service account is required to authenticate the requests sent to a Cloud Run service. If you do not already have a service account, follow instructions on this page in order to create one.

Before using the library the service account must be authenticated to send requests to the Cloud Run service following these steps.

use CodeInc\CloudRunAuthHttpClient\HttpClientFactory;

// create a new HttpClientFactory instance
$factory = new HttpClientFactory();

// create the client using a JSON file for the service account key
$httpClient = $factory->factory(
    // Cloud Run service URL
    'https://my-service-12345-uc.a.run.app',
    // path to your service account key 
    '/path/to/your/service-account-key.json' 
);

// create the client using a key stored in memory
$httpClient = $factory->factory(
    // Cloud Run service URL
    'https://my-service-12345-uc.a.run.app',
    // service account key 
    [
        'type' => 'service_account',
        // the rest of the service account key
    ]
);

// create the client using a key stored in a environment variable
$httpClient = $factory->factory(
    // Cloud Run service URL
    'https://my-service-12345-uc.a.run.app',
    // service account key 
    json_decode(getenv('SERVICE_ACCOUNT_KEY'), true)
);

License

The library is published under the MIT license (see LICENSE file).

统计信息

  • 总下载量: 50
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-03