PHP code example of effectra / http-factory

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

    

effectra / http-factory example snippets


use Effectra\Http\Factory\StreamFactory;

$streamFactory = new StreamFactory();
$stream = $streamFactory->createStream('Hello, world!');

use Effectra\Http\Factory\RequestFactory;

$requestFactory = new RequestFactory();
$request = $requestFactory->createRequest('GET', 'https://example.com');

use Effectra\Http\Factory\ServerRequestFactory;

$serverRequestFactory = new ServerRequestFactory();
$serverRequest = $serverRequestFactory->createServerRequest('POST', '/submit-form', $_SERVER);

use Effectra\Http\Factory\ResponseFactory;

$responseFactory = new ResponseFactory();
$response = $responseFactory->createResponse(200, 'OK');

use Effectra\Http\Factory\UriFactory;

$uriFactory = new UriFactory();
$uri = $uriFactory->createUri('https://example.com');