PHP code example of philharmony / http-psr-extension

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

    

philharmony / http-psr-extension example snippets


use Philharmony\Http\PsrExtension\UploadedFileFactoryFromFileInterface;

if ($factory instanceof UploadedFileFactoryFromFileInterface) {
$file = $factory->createUploadedFileFromFile(
    file: '/tmp/file.txt',
    size: 1024,
    errorStatus: UPLOAD_ERR_OK,
    clientFilename: 'avatar.png',
    clientMediaType: 'image/png',
    fullPath: 'users/avatars/avatar.png' // PHP 8.1+ support   
);
} else {
// fallback to PSR-17
}

use Philharmony\Http\PsrExtension\UploadedFileFullPathInterface;

if ($uploadedFile instanceof UploadedFileFullPathInterface) {
    $fullPath = $uploadedFile->getFullPath();
} else {
// fallback to PSR-17  
}