PHP code example of thingston / psr17

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

    

thingston / psr17 example snippets




declare(strict_types=1);

use Thingston\Psr17\RequestFactory;
use Thingston\Psr17\ResponseFactory;
use Thingston\Psr17\ServerRequestFactory;
use Thingston\Psr17\StreamFactory;
use Thingston\Psr17\UploadedFileFactory;
use Thingston\Psr17\UriFactory;

$requestFactory = new RequestFactory();
$responseFactory = new ResponseFactory();
$serverRequestFactory = new ServerRequestFactory();
$streamFactory = new StreamFactory();
$uploadedFileFactory = new UploadedFileFactory();
$uriFactory = new UriFactory();

$request = $requestFactory->createRequest('POST', 'https://example.com/articles');
$response = $responseFactory->createResponse(201);
$serverRequest = $serverRequestFactory->createServerRequest(
    'GET',
    'https://example.com/search?q=psr',
    ['HTTPS' => 'on'],
);
$stream = $streamFactory->createStream('payload');
$uploadedFile = $uploadedFileFactory->createUploadedFile(
    $streamFactory->createStream('file contents'),
    null,
    UPLOAD_ERR_OK,
    'example.txt',
    'text/plain',
);
$uri = $uriFactory->createUri('https://example.com/path?foo=bar');