Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ddrv/php-http-client
simple HTTP client on PHP without cURL
https://github.com/ddrv/php-http-client
Last synced: about 2 months ago
JSON representation
simple HTTP client on PHP without cURL
- Host: GitHub
- URL: https://github.com/ddrv/php-http-client
- Owner: ddrv
- License: mit
- Created: 2018-06-03T13:17:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-14T12:48:08.000Z (about 4 years ago)
- Last Synced: 2023-08-21T09:20:29.070Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![Latest Stable Version](https://img.shields.io/packagist/v/ddrv/http-client.svg?style=flat-square)](https://packagist.org/packages/ddrv/http-client)
[![Total Downloads](https://img.shields.io/packagist/dt/ddrv/http-client.svg?style=flat-square)](https://packagist.org/packages/ddrv/http-client/stats)
[![License](https://img.shields.io/packagist/l/ddrv/http-client.svg?style=flat-square)](https://github.com/ddrv/php-http-client/blob/master/LICENSE)
[![PHP](https://img.shields.io/packagist/php-v/ddrv/http-client.svg?style=flat-square)](https://php.net)# ddrv/http-client
Simple HTTP client without cURL dependency. Required `allow_url_fopen` option in `php.ini` file.
```ini
; php.ini
allow_url_fopen = On
```# Install
Install this package, your favorite [psr-7 implementation](https://packagist.org/providers/psr/http-message-implementation) and your favorite [psr-17 implementation](https://packagist.org/providers/psr/http-factory-implementation).
```bash
composer require ddrv/http-client:^2.0
```# Using
```php
sendRequest($request);$code = $response->getStatusCode();
$phrase = $response->getReasonPhrase();
$headers = $response->getHeaders();
$someHeader = $response->getHeader('Content-Type');$body = $response->getBody()->__toString();
```# Configuration
```php
setFollowRedirects(0); // Set 0 follow redirects (disable).
$http->setTimeOut(10); // Set connection timeout 10 seconds$http->setProxy($proxy); // Set proxy
$http->setProxy(); // Unset proxy
```# SSL Authorization
```php
setSslAuth('host', 'ssl.crt', 'ssl.key'); // without password
$http->setSslAuth('host', 'ssl.crt', 'ssl.key', 'p@s$w0rd'); // with password
$http->unsetSslAuth('host'); // disable
```