PHP code example of waffle-commons / http

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

    

waffle-commons / http example snippets


use Waffle\Commons\Http\Factory\GlobalsFactory;

$factory = new GlobalsFactory();
$request = $factory->createFromGlobals(); // PSR-7 ServerRequestInterface

public function __construct(?callable $bodyStreamFactory = null)

use Waffle\Commons\Http\Emitter\ResponseEmitter;
use Waffle\Commons\Http\Factory\ResponseFactory;

$response = (new ResponseFactory())
    ->createResponse(200)
    ->withHeader('Content-Type', 'application/json');

(new ResponseEmitter())->emit($response);