2017 © Pedro Peláez
 

library http-client

simple HTTP client without cURL dependency

image

ddrv/http-client

simple HTTP client without cURL dependency

  • Tuesday, June 5, 2018
  • by ddrv
  • Repository
  • 0 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Latest Stable Version Total Downloads License PHP, (*1)

ddrv/http-client

Simple HTTP client without cURL dependency. Required allow_url_fopen option in php.ini file., (*2)

; php.ini
allow_url_fopen = On

Install

Install this package, your favorite psr-7 implementation and your favorite psr-17 implementation., (*3)

composer require ddrv/http-client:^2.0

Using

<?php

use Ddrv\Http\Client\Client;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseFactoryInterface;

/** 
 * @var ResponseFactoryInterface $responseFactory
 * @var int $timeout = 60
 * @var int $redirects = 0
 */
$http = new Client($responseFactory, $timeout, $redirects);

/** @var RequestInterface $request */
$response = $http->sendRequest($request);

$code = $response->getStatusCode();
$phrase = $response->getReasonPhrase();
$headers = $response->getHeaders();
$someHeader = $response->getHeader('Content-Type');

$body = $response->getBody()->__toString();

Configuration

<?php

use Ddrv\Http\Client\Client;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\UriInterface;

/**
 * @var ResponseFactoryInterface $responseFactory
 * @var UriInterface $proxy
 */

$http = new Client($responseFactory);

$http->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

use Ddrv\Http\Client\Client;
use Psr\Http\Message\ResponseFactoryInterface;

/**
 * @var ResponseFactoryInterface $responseFactory
 */

$http = new Client($responseFactory);

$http->setSslAuth('host', 'ssl.crt', 'ssl.key'); // without password
$http->setSslAuth('host', 'ssl.crt', 'ssl.key', 'p@s$w0rd'); // with password
$http->unsetSslAuth('host'); // disable

The Versions

05/06 2018

dev-master

9999999-dev

simple HTTP client without cURL dependency

  Sources   Download

MIT

The Requires

  • php >=5.3

 

http client http-client without-curl

05/06 2018

1.0.1

1.0.1.0

simple HTTP client without cURL dependency

  Sources   Download

MIT

The Requires

  • php >=5.3

 

http client http-client without-curl

04/06 2018

1.0.0

1.0.0.0

simple HTTP client without cURL dependency

  Sources   Download

MIT

The Requires

  • php >=5.3

 

http client http-client without-curl

03/06 2018

0.9.0

0.9.0.0

simple HTTP client without cURL dependency

  Sources   Download

MIT

The Requires

  • php >=5.3

 

http client http-client without-curl