PHP code example of breakeneck / http

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

    

breakeneck / http example snippets


$jsonResponse = (new \Breakeneck\Http\Request())
    ->json()
    ->setData(['value' => 'param'])
    ->post('http://example.com/{route}', ['{route}' => 'api']);

print_r($jsonResponse->content);    

$xmlResponse = (new \Breakeneck\Http\Request())
    ->xml('root') // Parameter can be omitted, if your request doesn't contain body
    ->setData(['value' => 'param'])
    ->put('http://example.com/{route}', ['{route}' => 'api']);

print_r($xmlResponse->content);

$response = (new \Breakeneck\Http\Request())
    ->delete('http://example.com/{route}', ['{route}' => 'api']);
    
print_r($response->content);

$response = (new \Breakeneck\Http\Request())
    ->setData(['id' => 31])
    ->get('http:://example.com');
    
print_r($response->request->getUrl() === 'http:://example.com?id=31');

$response = (new \Breakeneck\Http\Request())
    ->addHeaders(['Content-Type' => 'application/text'])
    ->delete('http://example.com/{route}/id/{username}', ['{route}' => 'api', '{username}' => 'breakeneck']);