A traditional PHP request owns the whole process, so "which request is this?" never comes up. Servers like FrankenPHP, Swoole or a ReactPHP app handle many requests in one process, sometimes overlapping, and PHP has no built-in way to tell them apart. Frode Børli's RFC adds a Scope class: an object that stands for one unit of work, such as an HTTP request, a queue job or a CLI command.
Show me
// The server runs each request in its own scope: (new Scope())->run($handler, $request); // Code anywhere in that request can ask which request it belongs to: $this->connections ??= new WeakMap(); $db = $this->connections[Scope::getCurrent()] ??= new PDO($dsn);
A Scope holds no data itself. Libraries keep per-request state in a WeakMap keyed by the scope, and that state is cleaned up once nothing references the scope any more.
How it works
run()makes a scope current while a callback runs and restores the previous one afterwards, even when the callback throws.Scope::getCurrent()always returns an object. Outside anyrun()it returns the root scope,Scope::getRootScope(), so plain CLI and php-fpm code needs no changes.- One rule underneath. Every stack frame gets its scope when it's created, from the code that created it, and keeps it.
- Fibers run in the scope of the code that calls
start(). To pin a fiber to a scope, wrap its callback:new Fiber($scope->bind($fn)). - Generators keep the scope they were created in, whoever resumes them. So a streamed response generator keeps using its own request's services.
- Functions and closures run in their caller's scope. To make a callback always run in the scope that registered it, wrap it with
$scope->bind($closure). Generator::getScope()tells a scheduler which scope a generator belongs to.
A scope doesn't wait for or cancel work. It's an identity, not a task manager, and the RFC leaves cancellation to a later proposal.
Two optional votes
Besides the main vote, two secondary votes move specific global state into the scope:
- Vote A:
$_GET,$_POST,$_COOKIE,$_FILES,$_REQUEST,$_SERVERand the session become per scope. A new scope starts with a copy of its creator's values. A server creates each request's scope from its own loop, where that copy is as good as empty, and fills them in. Since version 0.9.3,session_start()throws aRuntimeExceptionif a locking session handler already has the same session open in another scope of the process, instead of blocking the whole process. The RFC lists that choice as its one open question; the alternative is letting both scopes share the session. - Vote B: the default timezone and the default
Localebecome per scope, also starting as a copy of the creator's.
Output buffers, error handlers and ini_set() values stay shared for now, and the RFC leaves each to its own future RFC. So do persistent database connections, which two scopes could otherwise end up sharing.
What it means for existing code
Code that never creates a scope runs in the root scope and behaves exactly as before. The one break is the class name: a class called Scope in the global namespace can no longer be declared. Namespaced classes like Laravel's Illuminate\Database\Eloquent\Scope aren't affected, and the author found no global Scope class among the top 1,000 Composer packages.
Where it stands
Frode Børli opened the internals discussion on October 26, 2026. The RFC targets PHP 8.7. A working extension and polyfill exist, and the php-src pull request is planned before the vote. Version 0.10, on November 13, rewrote the RFC around the stack-frame rule. It dropped Fiber::getScope(), and after feedback from Larry Garfield and Côme Chilliet, new scopes now copy their creator's state instead of starting empty. The main vote needs a two-thirds majority, and the two secondary votes need a simple majority each.