teamreflex/ChallongePHP

Library is not compatible with all PSR-18 clients

Closed this issue · 3 comments

The following lines in ClientWrapper.php use a Guzzle-specific call that does not work with a standard PSR-18 client:

$response = $this->client->request($method, $base_uri, [
'query' => ['api_key' => $this->getKey()],
'form_params' => $content,
'headers' => $this->buildHeaders(),
'http_errors' => false,
'verify' => false,
]);

For example, when used with the Symfony HTTP client, I receive this error:
Attempted to call an undefined method named "request" of class "Symfony\Component\HttpClient\Psr18Client".

The best approach would be to pass down a RequestFactoryInterface (as defined in PSR-17) in order to construct a PSR-7 request. This might require a breaking change to the Challonge class, so an alternative option could be to add a dependency on a specific PSR-7 implementation and construct the request object directly. In both cases, you would then pass that request object to $this->client->sendRequest().

That's awkward, serves me right for just assuming it'd work. Just pushed a fix to master, let me know if that fixes it and I'll tag it.

Pulled from master and it looks good to me 👍

Tagged at 3.1, thanks for the heads up 😊