PHP code example of phpstandard / raw-request-factory

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

    

phpstandard / raw-request-factory example snippets




use Framework\Http\RawRequestFactory;

// Any implementation of the Psr\Http\Message\ServerRequestFactoryInterface
$server_request_factory = new ServerRequestFactory;

// Any implementation of the Psr\Http\Message\StreamFactoryInterface
$stream_factory = new StreamFactory;

// In most cases this will be a server request
// captured from globals (a real http request to the server).
$server_request = $server_request_factory->createServerRequest('POST', 'https://example.com');

$factory = new RawRequestFactory($server_request_factory, $stream_factory);

// Create a raw HTTP request string from the ServerRequestFactoryInterface implementation
$raw_request = $factory->createRawRequest($server_request);

// Create a server request from the raw HTTP request string
$new_server_request = $factory->createServerRequest($raw_request);