Factory interfaces for PSR-7 HTTP Message.
Via Composer
$ composer require php-http/message-factoryThe FIG was pretty straightforward by NOT putting any construction logic into PSR-7. However there is a need for that. This does not try to be the "de facto" way to do message construction, but tries to provide an easy way to construct messages by following already existing patterns. (For example: MessageFactory accepts parameters in the order they appear in a request/response: method, uri, protocol version, headers, body (in case of a request)).
This package provides interfaces for PSR-7 factories including:
MessageFactoryServerRequestFactory- WIP (PRs welcome)StreamFactoryUploadedFileFactory- WIP (PRs welcome)UriFactoryClientContextFactory(CombinesMessageFactory,StreamFactoryandUriFactory)
A virtual package (php-http/message-factory-implementation) MAY be introduced which MUST be versioned together with this package.
use Http\Message\SomeFactory;
class MyFactory implements SomeFactory
{
}For each factory there is a helper interface and trait to ease injecting them into other objects (such as HTTP clients).
An example:
use Http\Message\SomeFactoryAware;
use Http\Message\SomeFactoryAwareTemplate;
class HttpClient implements SomeFactoryAware
{
use SomeFactoryAwareTemplate;
}
$client = new HttpClient();
$someFactory = $client->getSomeFactory();
$client->setSomeFactory($someFactory);Please see CONTRIBUTING for details.
If you discover any security related issues, please contact us at [email protected].
The MIT License (MIT). Please see License File for more information.