philharmony/http-psr-extension

Optional extensions for PSR-7 and PSR-17 HTTP interfaces

Maintainers

Package info

github.com/philharmonytech/http-psr-extension

pkg:composer/philharmony/http-psr-extension

Statistics

Installs: 72

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-03-29 14:20 UTC

This package is auto-updated.

Last update: 2026-03-29 14:25:09 UTC


README

PHP Version PSR Latest Stable Version Total Downloads License

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 instanceof for 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.