PHP code example of dspacelabs / http-message

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

    

dspacelabs / http-message example snippets


use Dspacelabs\Component\Http\Message\Uri;

$uri = (new Uri())
    ->withScheme('http')
    ->withHost('www.example.com');

use Dspacelabs\Component\Http\Message\Uri;

$uri = new Uri('http://www.example.com');

use Dspacelabs\Component\Http\Message\Uri;
use Dspacelabs\Component\Http\Message\Request;

$request = new Request();
$request
    ->withMethod('GET')
    ->withUri(new Uri('http://www.example.com'));


use Dspacelabs\Component\Http\Message\Response;

$resposne = new Response();
$response
    ->withStatus(200, 'OK');