mini\Http\RequestGlobalProxy class

Documentation

ArrayAccess proxy for request globals ($_GET, $_POST, $_COOKIE)

Transparently proxies array access to PSR-7 ServerRequest methods, enabling fiber-safe concurrent request handling without code changes.

Traditional PHP behavior:

$id = $_GET['id'];           // Direct superglobal access
$name = $_POST['name'];      // Process-wide variables

With RequestGlobalProxy:

$_GET = new RequestGlobalProxy('query');     // Install once at startup
$_POST = new RequestGlobalProxy('post');

// User code unchanged - transparently uses current request
$id = $_GET['id'];           // → gets from current ServerRequest
$name = $_POST['name'];      // → gets from current ServerRequest

Benefits:

  • Zero code changes needed - existing $_GET['id'] works unchanged
  • Fiber-safe by default - each fiber gets its own request context
  • Works with all SAPIs (FPM, CGI, mod_php, Swoole, ReactPHP, phasync)
  • Consistent architecture - no special adapters needed

Limitations:

  • Cannot modify request globals ($_GET['x'] = 'y' throws exception)
  • Use PSR-7 withQueryParams() to modify request instead
  • is_array($_GET) returns false (use isset(), array access works fine)

Inheritance

Implements: ArrayAccess Countable IteratorAggregate Traversable

Properties (1)

private readonly string $source

Methods (9)

Documentation missing

Get value from current request context

Check if key exists in current request context

Setting values not supported - use PSR-7 methods instead

Unsetting values not supported - use PSR-7 methods instead

Count elements in current request context

Get iterator for current request context

Get data from current request's ServerRequest

Debug info for var_dump()

Source

src/Http/RequestGlobalProxy.php:44-178