phrity / http
Utilities and interfaces for handling HTTP.
Requires
- php: ^8.1
- psr/http-factory: ^1.0
- psr/http-message: ^1.1 | ^2.0
Requires (Dev)
- guzzlehttp/psr7: ^2.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.0 | ^11.0 | ^12.0
- robiningelbrecht/phpunit-coverage-tools: ^1.9
- squizlabs/php_codesniffer: ^3.5
README
Phrity Http
Utilities and interfaces for handling HTTP.
Installation
Install with Composer;
composer require phrity/http
Phrity HttpFactory
Convenience wrapper for HTTP factories, where you can add all or any factories to the same class. The class will then delegate to actual implementation. If any implementation is missing, a BadMethodCallException will be thrown.
Supports RequestFactoryInterface, ResponseFactoryInterface, ServerRequestFactoryInterface, StreamFactoryInterface, UploadedFileFactoryInterface and UriFactoryInterface from PSR-17.
$factory = new Phrity\Http\HttpFactory( requestFactory: $requestFactoryImplementation, responseFactory: $responseFactoryImplementation, serverRequestFactory: $serverRequestFactoryImplementation, streamFactory: $streamFactoryImplementation, uploadedFileFactory: $ruploadedFileFactoryImplementation, uriFactory: $uriFactoryImplementation, );
Popular PSR-17 implementations, such as Nyholm and Guzzle, often offer factories that support all interfaces.
By using the create()
method, the HttpFactory can take any implementation and configure the HttpFactory class with the factories the implementation supports.
$guzzlePsr7 = new GuzzleHttp\Psr7\HttpFactory(); $factory = Phrity\Http\HttpFactory::create($guzzlePsr7);
Versions
Version | PHP | |
---|---|---|
1.0 |
^8.1 |
HttpFactory convenience wrapper |