PHP code example of rogerthomas84 / ohhttp

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

    

rogerthomas84 / ohhttp example snippets


$request = new \OhHttp\Request();
if ($request->isGet()) {
    $userId = $request->getParam('id', null);
    // do something
} elseif ($request->isPost()) {
    $userId = $request->getParam('id', null);
    // do something
}

$response = new \OhHttp\Response();
$response->setHeader('Content-Type', 'application/json');
$response->setBody('{"foo":"bar"}');
$response->send();