Skip to content

raph6/httprequest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ba2a6d8 · Sep 8, 2021

History

29 Commits
Apr 12, 2021
Mar 24, 2021
Feb 19, 2021
Apr 12, 2021
Sep 8, 2021
Feb 19, 2021

Repository files navigation

HttpRequest

composer package for http request using curl

Installation

composer require raph6/httprequest

Example of use

use raph6\HttpRequest\HttpRequest;

# url
$http = new HttpRequest('https://httpbin.org/anything');
# or 
$http = new HttpRequest;
$http->setUrl('https://httpbin.org/anything')

# cookies
     ->setCookies(['bar' => 'foo'])

# data (get or post)
     ->setData(['foo' => 'bar'])

# headers
     ->setHeaders(['token' => '123456'])

# user agent
     ->setUserAgent('PHP/Curl (https://github.com/raph6/httprequest)')

# basic auth
     ->setBasicAuth('username', 'password')

# timeout (default 10)
     ->setTimeout(5);

var_dump($http->post());
// var_dump($http->get());