PHP code example of simplecomplex / restmini

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

    

simplecomplex / restmini example snippets


use SimpleComplex\RestMini\Client;

// Get JSON-decoded response data.
$data = Client::make('http://server', '/endpoint', [
    'headers' => [
        'X-Whatever' => 'Hello',
    ],
    'json_parse_assoc' => true,
])->get(
    [
        'some-path-arg' => 'foo',
    ],
    [
        'some-query-arg' => 'bar',
    ]
)->result();

// Check status first.
$response = Client::make('http://server', '/endpoint')->get();
if ($response->status() == 200) {
    $data = $response->result();
}
else {
    $info = $response->info();
    $container = \SimpleComplex\Utils\Dependency::container();
    $container->get('logger')->warning("Darned:\n" . json_encode($info, JSON_PRETTY_PRINT));
}

// Get raw response data.
$raw = Client::make('http://server', '/endpoint')->get()->raw():