rfc:http-interface

This is an old revision of the document!


PHP RFC: Standardized PHP Http Interface

Standardizing and building an HTTP interface in PHP for allowing clients to implement their own custom Http Request/Response objects without having to wrap a plethora of HTTP functions/classes/libraries.

Introduction

This RFC proposes creating one standard HTTP interface in PHP core that users can implement in their own PHP code to utilize HTTP request and response capabilities and discard the superglobal $_GET, $_POST, $_COOKIE, $_FILES, $_SERVER variables. Along with the interface a base HttpRequest and HttpResponse classes should be packaged with PHP so that users can extend or override such default behavior at will and with efficiency. If the user does not chose to implement their own HTTP classes using the HTTP interface then default behavior is relied upon by PHP.

Proposal

This RFC proposes creating one standard Http interface in PHP core along with two base classes: HttpRequest and HttpResponse that handle all incoming and outgoing HTTP messages through a unified interface.

The ultimate goal of this proposal is to make HTTP message handling in PHP ubiquitous and conforming. Superglobal variables such as $_POST and $_GET are great, but they do not address many of the concerns that current web users are dealing with today such as RESTful APIs. Some RESTful APIs might rely on PUT and DELETE HTTP verbs (methods) to handle certain requests and PHP does not make dealing with such requests intuitive. So some users requested $_PUT and $_DELETE superglobals to be added to the list. However, this RFC does not propose such features. Instead, it is proposed to rid PHP of the super global variables entirely and make HTTP message processing a standard interface that can be implement by the user in any way they deem fit.

This greatly reduces the need to change core PHP for any form of edge cases that may rely on processing HTTP messages differently and improves the flexibility and extensibility of PHP's built-in message processing facilities.

Backward Incompatible Changes

Superglobal variables including $_GET, $_POST, $_FILES, $_COOKIE, and $_SERVER will be removed. PHP will no longer automatically parse incoming HTTP request bodies during request initialization. Instead, request bodies will be lazy loaded by the interface and handled directly by implementing objects.

Proposed PHP Version(s)

PHP 7.0.x or PHP 7.NEXT

RFC Impact

To SAPIs

No known impact on individual SAPIs.

To Existing Extensions

None.

To Opcache

Uknown

New Constants

Only individual class constants should be added.

php.ini Defaults

No runtime or loaded configuration changes.

Open Issues

Unaffected PHP Functionality

Future Scope

Proposed Voting Choices

Language change. Requires 2/3 majority vote.

Patches and Tests

Implementation

References

Rejected Features

rfc/http-interface.1414692377.txt.gz · Last modified: 2017/09/22 13:28 (external edit)