philharmony / http-psr-extension
Optional extensions for PSR-7 and PSR-17 HTTP interfaces
Package info
github.com/philharmonytech/http-psr-extension
pkg:composer/philharmony/http-psr-extension
Requires
- php: ^8.1
- psr/http-factory: ^1.0
- psr/http-message: ^2.0
README
Optional extensions for PSR-7 and PSR-17 HTTP interfaces
📦 Installation
composer require philharmony/http-psr-extension
🧠 Overview
This 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.
⚙️ Philosophy
- PSR interfaces remain the baseline
- Extensions are optional
- Use
instanceoffor capability detection - Always provide a fallback to standard PSR behavior
🚀 Usage
Detect extended UploadedFileFactory
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 }
Detect full path support
use Philharmony\Http\PsrExtension\UploadedFileFullPathInterface; if ($uploadedFile instanceof UploadedFileFullPathInterface) { $fullPath = $uploadedFile->getFullPath(); } else { // fallback to PSR-17 }
🔌 Compatibility
- Works with any PSR-7 implementation
- Works with any PSR-17 factory
- No runtime dependencies
📄 License
This package is open-source and licensed under the MIT License. See the LICENSE file for details.
🤝 Contributing
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.
⭐ Support
If you find this package useful, please consider giving it a star on GitHub. It helps the project grow and reach more developers.