Skip to content
This repository was archived by the owner on May 13, 2023. It is now read-only.

php-http/message-factory

Repository files navigation

HTTP Message Factory

Latest Version Software License Total Downloads

Factory interfaces for PSR-7 HTTP Message.

Install

Via Composer

$ composer require php-http/message-factory

Rationale

The 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)).

Usage

This package provides interfaces for PSR-7 factories including:

  • MessageFactory
  • ServerRequestFactory - WIP (PRs welcome)
  • StreamFactory
  • UploadedFileFactory - WIP (PRs welcome)
  • UriFactory
  • ClientContextFactory (Combines MessageFactory, StreamFactory and UriFactory)

A virtual package (php-http/message-factory-implementation) MAY be introduced which MUST be versioned together with this package.

General usage

use Http\Message\SomeFactory;

class MyFactory implements SomeFactory
{

}

Factory awares and templates

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);

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please contact us at security@php-http.org.

License

The MIT License (MIT). Please see License File for more information.

About

Abandoned: Httplug Factory interfaces for PSR-7 HTTP Message

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 5

Languages