PHP code example of rymanalu / http

1. Go to this page and download the library: Download rymanalu/http 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/ */

    

rymanalu / http example snippets


use Rymanalu\Http\Endpoint;

class BarEndpoint extends Endpoint
{
    /**
     * The endpoint's URI.
     *
     * @var string
     */
    protected $uri = 'bar';

    /**
     * The endpoint's method.
     *
     * @var string
     */
    protected $method = 'POST';
}

$http = new Rymanalu\Http\Client('http://foo.com');

$endpoint = new BarEndpoint; // or `new BarEndpoint($anArrayOfGuzzleOptions)`

$response = $http->call($endpoint);

// Check if the calls is successful by the response code...
$response->isSuccessful(); // `true` or `false`

// Get the response body...
$response->getBody(); // object of `stdClass`
$response->getBody(true); // array