Skip to content

philharmonytech/http-psr-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http-psr-extension

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.

About

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

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages