PHP code example of guennichi / psr7-request-creator

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

    

guennichi / psr7-request-creator example snippets


$psr17Factory = new Nyholm\Psr7\Factory\Psr17Factory();

$serverRequestCreator = new Nyholm\Psr7Server\ServerRequestCreator(
    $psr17Factory, // ServerRequestFactory
    $psr17Factory, // UriFactory
    $psr17Factory, // UploadedFileFactory
    $psr17Factory, // StreamFactory
);

// Psr\Http\Message\ServerRequestInterface instance
$serverRequest = $serverRequestCreator->fromGlobals();

$requestCreator = new Guennichi\Psr7RequestFactory\RequestCreator(
    $psr17Factory, // RequestFactory
    $psr17Factory, // StreamFactory
    new Http\Message\MultipartStream\MultipartStreamBuilder($psr17Factory),
);

// Psr\Http\Message\RequestInterface instance
$request = $requestCreator->fromServerRequest('/example', $serverRequest);