alextartan / guzzle-psr18-adapter
Lightweight wrapper over Guzzle to comply with PSR18
Installs: 191 275
Dependents: 3
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: >=7.4||>=8.0
- guzzlehttp/guzzle: ^7
- psr/http-client: ^1.0.0
- psr/http-message: ^1.0.0
Requires (Dev)
- ext-mbstring: *
- ext-xml: *
- infection/infection: ^0.20
- php-coveralls/php-coveralls: ^2.4
- phpstan/phpstan: ^0.12
- phpstan/phpstan-phpunit: ^0.12
- phpstan/phpstan-strict-rules: ^0.12
- phpunit/phpunit: ^9
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: 3.5.*
README
Guzzle Adapter for PSR-18
Wrapper over Guzzle to comply with PSR-18
Current build status
Install
The easiest way is to use composer
:
composer require alextartan/guzzle-psr18-adapter
Note: requires PHP
>= 7.2
Usage
Example:
<?php
use Psr\Http\Client\ClientInterface;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\NetworkExceptionInterface;
use Psr\Http\Client\RequestExceptionInterface;
use GuzzleHttp\Psr7\Request;
[...]
public function sendSomething(ClientInterface $client, $data)
{
// Using GuzzleHttp\Psr7\Request in this example, but any implementation of PSR-7 will do
$request = new Request('GET', 'https://some-domain.com/something');
try{
// response is also an implementation of PSR-7 (Psr\Http\Message\ResponseInterface)
$response = $client->sendRequest($request)
} catch(ClientException $e){
// do something
} catch(NetworkException $e){
// do something
} catch(RequestException $e){
// do something
}
}
[...]
Issues and pull requests.
Any issues found should be reported in this repository issue tracker, issues will be fixed when possible. Pull requests will be accepted, but please adhere to the PSR2 coding standard. All builds must pass in order to merge the PR.