Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Changing guzzle adapter options

未关闭
#85 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
php
领域
api

调研方向

定位 API 客户端的构造函数以及 issue 中所示的 Guzzle 客户端创建代码。检查其 base URI 和 headers 当前的配置方式,然后确定哪种提议的选项形式适合现有的公共 API。完成标准是调用方可以配置 CA 文件或其他 Guzzle 选项,而无需编辑 php.ini 或环境设置。

由索引模型根据 Issue 内容生成。

描述

I've come across this issue while testing your api. Guzzle throws an exception complaining there's no ca file on a windows box. For those OS' without a default known ca file, see guzzle verify, it is not possible to set a default ca-file without altering the php.ini or PATH environment. To solve this issue,

Either

//to set options to the guzzle client
public getClient() { return $this->client; }

Or

public function __construct(Auth $auth, string $baseURI = null, $guzzleConfig = [])
{
    if ($baseURI === null) {
        $baseURI = 'https://api.cloudflare.com/client/v4/';
    }

    $headers = $auth->getHeaders();

    $config = [
        'base_uri' => $baseURI,
        'headers' => $headers,
        'Accept' => 'application/json'
    ] + $guzzleConfig;

    $this->client = new Client($config);
}    

Or

public function __construct(Auth $auth, string $baseURI = null, $caFile = false)
{
    if ($baseURI === null) {
        $baseURI = 'https://api.cloudflare.com/client/v4/';
    }

    $headers = $auth->getHeaders();

    $config = [
        'base_uri' => $baseURI,
        'headers' => $headers,
        'Accept' => 'application/json'
    ];

    if ($caFile !== false) $config['verify'] = $caFile;

    $this->client = new Client($config);
} 

can be done.

主要语言
PHP
星标
674
派生
268
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cloudflare/cloudflare-php 的其他 Issue

查看 cloudflare/cloudflare-php 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。