PHP code example of tiny-blocks / http

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

    

tiny-blocks / http example snippets


$httpCode = HttpCode::CREATED;

$httpCode->name;      # CREATED
$httpCode->value;     # 201
$httpCode->message(); # 201 Created

$method = HttpMethod::GET;

$method->name;  # GET
$method->value; # GET

$data = new Xyz(value: 10);
$response = HttpResponse::ok(data: $data);

$response->getStatusCode();          # 200
$response->getReasonPhrase();        # 200 OK
$response->getBody()->getContents(); # {"value":10}