Skip to content

Superglobal Mapping ​

RestPHP maps all standard HTTP protocol structures directly into native PHP superglobals with zero data corruption.


1. $_SERVER ​

RestPHP populates CGI and HTTP headers into $_SERVER using PHP's internal php_register_variable_safe() API:

HTTP Request Property$_SERVER KeyExample Value
HTTP MethodREQUEST_METHOD"POST"
Request PathREQUEST_URI"/api/users"
Query StringQUERY_STRING"role=admin&active=1"
HTTP ProtocolSERVER_PROTOCOL"HTTP/1.1"
Content-TypeCONTENT_TYPE"application/json"
Content-LengthCONTENT_LENGTH"1024"
Custom Header X-Custom-TokenHTTP_X_CUSTOM_TOKEN"secret123"

Headers are automatically capitalized and prefixed with HTTP_ according to CGI RFC 3875 standards.


2. $_GET ​

Query parameters are forwarded directly to the SAPI request context:

  • URL-encoded strings (e.g. %20, %26) are automatically decoded by Zend's standard query parser.
  • Query arrays (e.g. ?filter[status]=active&filter[type]=user) are parsed into native multidimensional PHP arrays.

3. $_POST and php://input ​

RestPHP implements the SAPI read_post callback:

  • application/x-www-form-urlencoded: The body is parsed automatically into $_POST.
  • application/json & Binary Payloads: Raw request payloads are streamable via file_get_contents('php://input') or fopen('php://input', 'rb') with zero truncation.

The incoming HTTP Cookie header is supplied to Zend via the SAPI read_cookies callback:

  • Multiple cookies separated by semicolons are parsed directly into $_COOKIE.
  • Missing or malformed cookie headers are safely ignored with zero null pointer dereferences.

Released under the MIT / Apache-2.0 License. Powered by Rust & Zend Engine.