├── CHANGELOG.md ├── CONTRIBUTING ├── LICENSE ├── README.md ├── composer.json ├── puli.json └── src ├── MessageFactory.php ├── RequestFactory.php ├── ResponseFactory.php ├── StreamFactory.php └── UriFactory.php /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | 4 | ## 1.1.0 - 2023-04-14 5 | 6 | ### Changed 7 | 8 | - Allow `psr/http-message` v2 in addition to v1 9 | - Deprecate all interfaces in favor of [PSR-17](https://www.php-fig.org/psr/psr-17/) 10 | 11 | ## 1.0.2 - 2015-12-19 12 | 13 | ### Added 14 | 15 | - Request and Response factory binding types to Puli 16 | 17 | 18 | ## 1.0.1 - 2015-12-17 19 | 20 | ### Added 21 | 22 | - Puli configuration and binding types 23 | 24 | 25 | ## 1.0.0 - 2015-12-15 26 | 27 | ### Added 28 | 29 | - Response Factory in order to be reused in Message and Server Message factories 30 | - Request Factory 31 | 32 | ### Changed 33 | 34 | - Message Factory extends Request and Response factories 35 | 36 | 37 | ## 1.0.0-RC1 - 2015-12-14 38 | 39 | ### Added 40 | 41 | - CS check 42 | 43 | ### Changed 44 | 45 | - RuntimeException is thrown when the StreamFactory cannot write to the underlying stream 46 | 47 | 48 | ## 0.3.0 - 2015-11-16 49 | 50 | ### Removed 51 | 52 | - Client Context Factory 53 | - Factory Awares and Templates 54 | 55 | 56 | ## 0.2.0 - 2015-11-16 57 | 58 | ### Changed 59 | 60 | - Reordered the parameters when creating a message to have the protocol last, 61 | as its the least likely to need to be changed. 62 | 63 | 64 | ## 0.1.0 - 2015-06-01 65 | 66 | ### Added 67 | 68 | - Initial release 69 | 70 | ### Changed 71 | 72 | - Helpers are renamed to templates 73 | -------------------------------------------------------------------------------- /CONTRIBUTING: -------------------------------------------------------------------------------- 1 | Please see http://docs.php-http.org/en/latest/development/contributing.html 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2016 PHP HTTP Team 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PSR-7 Message Factory 2 | 3 | [![Latest Version](https://img.shields.io/github/release/php-http/message-factory.svg?style=flat-square)](https://github.com/php-http/message-factory/releases) 4 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) 5 | [![Total Downloads](https://img.shields.io/packagist/dt/php-http/message-factory.svg?style=flat-square)](https://packagist.org/packages/php-http/message-factory) 6 | 7 | **Factory interfaces for PSR-7 HTTP Message.** 8 | 9 | ## Obsolete 10 | 11 | The PHP-HTTP factories have become obsolete with the [PSR-17](https://www.php-fig.org/psr/psr-17/) factories standard. 12 | All major HTTP client implementors provide [PSR-17 factories](https://packagist.org/packages/psr/http-factory). 13 | 14 | This package will remain available for the time being to not break legacy code, but we encourage everybody to move to PSR-17. 15 | 16 | ## Install 17 | 18 | Via Composer 19 | 20 | ``` bash 21 | $ composer require php-http/message-factory 22 | ``` 23 | 24 | 25 | ## Documentation 26 | 27 | Please see the [official documentation](http://docs.php-http.org/en/latest/message/message-factory.html). 28 | 29 | 30 | ## Contributing 31 | 32 | Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). 33 | 34 | 35 | ## Security 36 | 37 | If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). 38 | 39 | 40 | ## License 41 | 42 | The MIT License (MIT). Please see [License File](LICENSE) for more information. 43 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "php-http/message-factory", 3 | "description": "Factory interfaces for PSR-7 HTTP Message", 4 | "license": "MIT", 5 | "keywords": ["http", "factory", "message", "stream", "uri"], 6 | "homepage": "http://php-http.org", 7 | "authors": [ 8 | { 9 | "name": "Márk Sági-Kazár", 10 | "email": "mark.sagikazar@gmail.com" 11 | } 12 | ], 13 | "require": { 14 | "php": ">=5.4", 15 | "psr/http-message": "^1.0 || ^2.0" 16 | }, 17 | "autoload": { 18 | "psr-4": { 19 | "Http\\Message\\": "src/" 20 | } 21 | }, 22 | "extra": { 23 | "branch-alias": { 24 | "dev-master": "1.x-dev" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /puli.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "name": "php-http/message-factory", 4 | "binding-types": { 5 | "Http\\Message\\MessageFactory": { 6 | "description": "PSR-7 Message Factory", 7 | "parameters": { 8 | "depends": { 9 | "description": "Optional class dependency which can be checked by consumers" 10 | } 11 | } 12 | }, 13 | "Http\\Message\\RequestFactory": { 14 | "parameters": { 15 | "depends": { 16 | "description": "Optional class dependency which can be checked by consumers" 17 | } 18 | } 19 | }, 20 | "Http\\Message\\ResponseFactory": { 21 | "parameters": { 22 | "depends": { 23 | "description": "Optional class dependency which can be checked by consumers" 24 | } 25 | } 26 | }, 27 | "Http\\Message\\StreamFactory": { 28 | "description": "PSR-7 Stream Factory", 29 | "parameters": { 30 | "depends": { 31 | "description": "Optional class dependency which can be checked by consumers" 32 | } 33 | } 34 | }, 35 | "Http\\Message\\UriFactory": { 36 | "description": "PSR-7 URI Factory", 37 | "parameters": { 38 | "depends": { 39 | "description": "Optional class dependency which can be checked by consumers" 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/MessageFactory.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * @deprecated since version 1.1, use Psr\Http\Message\RequestFactoryInterface and Psr\Http\Message\ResponseFactoryInterface instead. 11 | */ 12 | interface MessageFactory extends RequestFactory, ResponseFactory 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /src/RequestFactory.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @deprecated since version 1.1, use Psr\Http\Message\RequestFactoryInterface instead. 15 | */ 16 | interface RequestFactory 17 | { 18 | /** 19 | * Creates a new PSR-7 request. 20 | * 21 | * @param string $method 22 | * @param string|UriInterface $uri 23 | * @param array $headers 24 | * @param resource|string|StreamInterface|null $body 25 | * @param string $protocolVersion 26 | * 27 | * @return RequestInterface 28 | */ 29 | public function createRequest( 30 | $method, 31 | $uri, 32 | array $headers = [], 33 | $body = null, 34 | $protocolVersion = '1.1' 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /src/ResponseFactory.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @deprecated since version 1.1, use Psr\Http\Message\ResponseFactoryInterface instead. 16 | */ 17 | interface ResponseFactory 18 | { 19 | /** 20 | * Creates a new PSR-7 response. 21 | * 22 | * @param int $statusCode 23 | * @param string|null $reasonPhrase 24 | * @param array $headers 25 | * @param resource|string|StreamInterface|null $body 26 | * @param string $protocolVersion 27 | * 28 | * @return ResponseInterface 29 | */ 30 | public function createResponse( 31 | $statusCode = 200, 32 | $reasonPhrase = null, 33 | array $headers = [], 34 | $body = null, 35 | $protocolVersion = '1.1' 36 | ); 37 | } 38 | -------------------------------------------------------------------------------- /src/StreamFactory.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | * @deprecated since version 1.1, use Psr\Http\Message\StreamFactoryInterface instead. 13 | */ 14 | interface StreamFactory 15 | { 16 | /** 17 | * Creates a new PSR-7 stream. 18 | * 19 | * @param string|resource|StreamInterface|null $body 20 | * 21 | * @return StreamInterface 22 | * 23 | * @throws \InvalidArgumentException if the stream body is invalid 24 | * @throws \RuntimeException if creating the stream from $body fails 25 | */ 26 | public function createStream($body = null); 27 | } 28 | -------------------------------------------------------------------------------- /src/UriFactory.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | * @deprecated since version 1.1, use Psr\Http\Message\UriFactoryInterface instead. 13 | */ 14 | interface UriFactory 15 | { 16 | /** 17 | * Creates an PSR-7 URI. 18 | * 19 | * @param string|UriInterface $uri 20 | * 21 | * @return UriInterface 22 | * 23 | * @throws \InvalidArgumentException if the $uri argument can not be converted into a valid URI 24 | */ 25 | public function createUri($uri); 26 | } 27 | --------------------------------------------------------------------------------