PHP code example of stadly / http

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

    

stadly / http example snippets

 php
use Stadly\Http\Header\Request\HeaderFactory as RequestHeaderFactory;
use Stadly\Http\Header\Response\HeaderFactory as ResponseHeaderFactory;

$requestHeaders = [
    'Content-Type: text/html; charset=UTF-8',
    'If-Match: "67ab43", "54ed21", W/"7892dd"',
    'Range: bytes=10-100, 200-300',
];
foreach ($requestHeaders as $headerString) {
    $header = RequestHeaderFactory::fromString($headerString);
}

$responseHeaders = [
    'Content-Type: multipart/form-data; boundary="abc def"',
    'Cache-Control: no-cache="foo, bar", max-age=120, must-revalidate',
    "Content-Disposition: attachment; filename=unicorn.jpg; filename*=UTF-8''%F0%9F%A6%84.jpg",
];
foreach ($responseHeaders as $headerString) {
    $header = ResponseHeaderFactory::fromString($headerString);
}