prim / httpfactory
PSR-17 factory with additional methods for clients and emitters.
1.1.0
2020-01-15 21:02 UTC
Requires
- php: >=7.2.0
- guzzlehttp/psr7: ^1.6
- laminas/laminas-httphandlerrunner: ^1.1
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- socialconnect/http-client: ^1.0
This package is auto-updated.
Last update: 2025-03-16 08:42:51 UTC
README
PSR-17 plus methods for clients and emitters.
This makes use of guzzlehttp/psr7, laminas-laminashttphandlerunner, and socialconnect/http-client to provide a simple factory that should handle most HTTP needs. Additionally it contains static methods for retrieving the names of the classes used in each implementation.
Usage
<?php
use Prim\HttpFactory\HttpFactory;
// PSR-17 creating objects implementing PSR-7
$response = (new HttpFactory)->createResponse();
$responseClass = HttpFactory::responseClass();
// PSR-18 HTTP client factory.
$client = (new HttpFactory)->createClient();
$clientClass = HttpFactory::clientClass();
// SAPI emitter factory.
$emitter = (new HttpFactory)->createEmitter();
$emitterClass = HttpFactory::emitterClass();
// PSR-7 server request from globals.
$request = (new HttpFactory)->createServerRequestFromGlobals();