PHP code example of tal7aouy / yusr

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

    

tal7aouy / yusr example snippets


use Yusr\Http\YusrClient;

// Get client instance
$client = YusrClient::getInstance();

// Make a GET request
$response = $client->get('https://api.example.com/users');

// Work with response
$statusCode = $response->getStatusCode();
$data = $response->getBody()->getContents();
$headers = $response->getHeaders();

$client = YusrClient::getInstance([
    'timeout' => 30,
    'allow_redirects' => true,
    'verify' => true,
    'retry' => [
        'max_attempts' => 3,
        'delay' => 1000 // milliseconds
    ]
]);

$client->get(string $uri, array $options = []);
$client->post(string $uri, array $options = []);
$client->put(string $uri, array $options = []);
$client->delete(string $uri, array $options = []);
$client->patch(string $uri, array $options = []);

$client = YusrClient::getInstance([
    'retry' => [
        'max_attempts' => 3,
        'delay' => 1000,
        'multiplier' => 2
    ]
]);