Optional extensions for PSR-7 and PSR-17 HTTP interfaces
composer require philharmony/http-psr-extensionThis package provides optional extension interfaces for PSR-7 and PSR-17.
It does not replace PSR standards, but adds additional capabilities that can be detected at runtime.
- PSR interfaces remain the baseline
- Extensions are optional
- Use
instanceoffor capability detection - Always provide a fallback to standard PSR behavior
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
}- Works with any PSR-7 implementation
- Works with any PSR-17 factory
- No runtime dependencies
This package is open-source and licensed under the MIT License. See the LICENSE file for details.
Contributions, issues, and feature requests are welcome.
If you find a bug or have an idea for improvement, please open an issue or submit a pull request.
If you find this package useful, please consider giving it a star on GitHub. It helps the project grow and reach more developers.