[RFC karma request] Scope: per-request state (superglobals, locale, timezone) for long-running and async PHP
| From: | Frode Børli | Date: | Mon, 19 Oct 2026 13:24:59 +0000 |
| Subject: | [RFC karma request] Scope: per-request state (superglobals, locale, timezone) for long-running and async PHP | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-132880@lists.php.net to get a copy of this message | ||
Hi internals,
Every long-running PHP server (Swoole, RoadRunner, FrankenPHP, phasync, and anything built on
fibers) hits the same wall: $_GET, $_POST, $_COOKIE, $_FILES, the default timezone and locale are
process-wide, so serving two requests at once means rewriting them behind the application’s back
or forbidding their use. The Scope RFC proposes the missing piece: a small class that identifies the
logical operation running code belongs to (a request, a job) and keeps that identity across fibers
and generators; two secondary votes let the five request superglobals and the default
timezone/locale follow the scope, so unmodified code sees its own request.
I’d like RFC karma for my wiki account, frodeborli. I’ve already submitted a karma request a few
days ago so this is a nudge with some more details to show I’ve done real work on this RFC.
The draft (version 0.7, target 8.7) is readable here while it waits for the wiki: https://fiber-interop.github.io/rfc-scope.html.
It comes with a reference implementation released today as a PIE extension for PHP 8.2–8.5,
fiber-interop/ext-scope 0.3.0 (https://github.com/fiber-interop/ext-scope), implementing the class
and both secondary votes with phpt tests, and a userland polyfill with the same tests
(fiber-interop/scope 0.3.0). It is in use by several event loops through the fiber-interop adapters,
which is where the semantics were worked out and measured.
I intend to publish the draft under https://wiki.php.net/rfc/scope and open discussion here
once it’s up. Some of you may remember me from the stream_select() FD_SETSIZE work (php-src
#14452).
Thanks,
Frode Børli