PHP code example of fastd / http

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

    

fastd / http example snippets


use FastD\Http\ServerRequest;

$request = ServerRequest::createServerRequestFromGlobals();

$request->getUri()->getPath();

$http = new swoole_http_server("127.0.0.1", 9501);

$http->on('request', function ($request, $response) {
    $server = SwooleServerRequest::createServerRequestFromSwoole($request);
    $response->end($server->getUri()->getPath());
});

$http->start();

$request = new Request('GET', 'https://api.github.com/');

$request->setReferrer('http://example.com/');

$response = $request->send(); // FastD\Http\Response