davidlienhard / httpclient
🐘 php library to make http requests
Installs: 3 446
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: ^8.0
- ext-curl: ^8.0
Requires (Dev)
- davidlienhard/coding-standard: ^1
- phpstan/phpstan: ^0 || ^1
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3
README
🐘 php library to send http requests
Setup
You can install through composer
with:
composer require davidlienhard/httpclient
Note: davidlienhard/httpclient requires PHP 8.0
Examples
Simple Example
<?php declare(strict_types=1); use DavidLienhard\HttpClient\Client; $http = new Client; $response = $http->get("https://test.com/"); echo $response->getHttpCode() === 200 ? "request was successful" : "request failed";
Do not verify SSL Cert
<?php declare(strict_types=1); use DavidLienhard\HttpClient\Client; use DavidLienhard\HttpClient\Request; $request = (new Request)->verifySslPeer(false); $http = new Client($request); $response = $http->get("https://test.com/"); echo $response->getHttpCode() === 200 ? "request was successful" : "request failed";
Add Cookies
<?php declare(strict_types=1); use DavidLienhard\HttpClient\Client; use DavidLienhard\HttpClient\Cookie; use DavidLienhard\HttpClient\CookieJar; use DavidLienhard\HttpClient\Request; $cookiejar = new CookieJar( new Cookie("name1", "value1"), new Cookie("name2", "value2") ); $http = new Client(cookiejar: $cookiejar); $response = $http->get("https://test.com/"); echo $response->getHttpCode() === 200 ? "request was successful" : "request failed";
License
The MIT License (MIT). Please see LICENSE for more information.