cloudflare / cloudflare/cloudflare-php

Changing guzzle adapter options

Open
#85 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
PHP
Stars
674
Forks
268
PR merge metrics
No merged PRs in 30d

Description

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](https://guzzle.readthedocs.io/en/stable/request-options.html#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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.