PHP code example of joseluisq / guztav

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

    

joseluisq / guztav example snippets




use Guztav\Client;

// Setting the client
$client = new \Guztav\Client([
    // Define these params if you don't use some .env file
    'base_uri' => 'http://localhost:8001/api/v1/',
    'access_token' => 'eyJ0eXBiOiJKV1QiLCN0bx.....', // Optional

    // More options...
    'headers' => ['Accept' => 'application/json'],
    'timeout'  => 2.0,
    ...
]);



use Guztav\Client;

$client = new \Guztav\Client();

// My GET request
$response = $client->get('client/1', [
    'query' => ['a' => 1, 'b' => 2]
]);
$string = $response->toString();


// My JSON POST request
$params = [
    'name' => 'Octocat',
    'email' => '[email protected]',
];
$array = $client->post('client', [
    'json' => $params
])->toArray();