PHP code example of fast-forward / http-message

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

    

fast-forward / http-message example snippets


use FastForward\Http\Message\JsonResponse;

$response = new JsonResponse(['success' => true]);

echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('Content-Type'); // application/json; charset=utf-8

echo (string) $response->getBody(); // {"success":true}

$newResponse = $response->withPayload(['success' => false]);

echo $response->getPayload()['success']; // true
echo $newResponse->getPayload()['success']; // false