PHP code example of jeyroik / json-reqres

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

    

jeyroik / json-reqres example snippets


$request = new Request([
  Request::FIELD__METHOD => Request::METHOD__GET,
  Request::FIELD__BASE_URL => 'https://github.com/',
  Request::FIELD__ENDPOINT => 'operationName',
  Request::FIELD__PARAMETERS => [
   'param1' => 'value1'
 ]
]);
 
$response = $request->run();

print_r($response->getResult(), true);

$request = new Request([
  Request::FIELD__METHOD => Request::METHOD__GET,
  Request::FIELD__BASE_URL => 'https://github.com/',
  Request::FIELD__ENDPOINT => 'operationName',
  Request::FIELD__DISPATCHER_REQUEST => '\\dispatcher\\class\\Name',
  Request::FIELD__DISPATCHER_RESPONSE => '\\dispatcher\\class\\Name',
  Request::FIELD__PARAMETERS => [
   'param1' => 'value1'
 ]
]);