PHP code example of drewlabs / psr7

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

    

drewlabs / psr7 example snippets


use Drewlabs\Psr7\Request;

// Instantiate the psr7 class
$request = new Request();

// Overriding the request method
$request = $request->withMethod('POST');

// Overriding request headers
$request = $request->withHeaders([
    // ...
]);

use Drewlabs\Psr7\Request;

// Instantiate the psr7 class
$response = new Response();

// Instantiate response with parameters
$response = new Response('', [/* Response headers */]);

// Overriding the response method
$response = $response->withStatusCode(404);

// Overriding response headers
$response = $response->withHeaders([
    // ...
]);

$uri = Uri::new(/* URI string | or Null */);