PHP code example of mawuekom / http-request-wrapper

1. Go to this page and download the library: Download mawuekom/http-request-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mawuekom / http-request-wrapper example snippets


// Simple usage

use Mawuekom\HttpRequestWrapper\HttpRequest;

$request = new HttpRequest('http://httpbin.org');
$response = $request ->send('GET', 'get');

echo $response ->getBody();

// Simple usage

use Mawuekom\HttpRequestWrapper\HttpRequest;

$request = new HttpRequest('http://httpbin.org');
$response = $request ->get('get');

// You can also override default base URI
$response = $request ->get('http://httpbin.org/get');

$request ->post('http://httpbin.org/post');
$request ->put('http://httpbin.org/put');
$request ->patch('http://httpbin.org/patch');
$request ->delete('http://httpbin.org/delete');

use Mawuekom\HttpRequestWrapper\Helpers\HttpRequestHelper;

class Test
{
    use HttpRequestHelper;

    private $baseUri = 'http://httpbin.org/';

    public function data()
    {
        $res = $this ->makeRequest('GET', 'get');

        return $res ->getBody();
    }

    public function getData()
    {
        $res = $this ->get('get');

        return $res ->getBody();
    }
}