Re: RFC proposal: worker mode primitives for SAPIs
| From: | Daniil Gentili | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: RFC proposal: worker mode primitives for SAPIs | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122118@lists.php.net to get a copy of this message | ||
Hi,
> But holding up the entire conversation because these things don't even
> exist,
BTW, I'm not asking to wait for the implementation of a native event loop before implementing a
worker mode, I'm asking to design the worker mode API in a way that is compatible with an
eventual native event loop (that I hope will eventually get merged into php, as the current status
quo of blocking STL I/O is definitely not ideal for a programming language in 2024).
Using superglobals for request information is already using a wrong approach in sight of native
async, and while technically this is not completely incompatible with fibers, as superglobals can
simply be copied immediately as soon a fiber is started, the same cannot be said for php://output
and php://input streams, which cannot be copied in any way.
I ask to completely avoid altering superglobals and other global state such as the
php://input/output streams, and instead directly pass/return an array/object (it really does not
matter to me if it's a PSR-7 RequestInterface or an array containing _GET, _POST, input, output
keys, or anything else as long as superglobals and global state is not touched in any way).
Backwards compatibility for code using superglobals is really a non-issue here, as worker mode in
itself is already potentially NOT automatically backwards-compatible with legacy code, since
applications running in worler mode have to deal with the fact that the global state is not reset at
the end of each request.
This in itself is not an issue as mentioned before, thanks to work inside of major PHP frameworks to
better support worker mode, I.e. laravel octane, but since the beneficiaries of worker mode will
mostly be modern frameworks and most legacy code will already require changes to better support it,
using a new API with a standalone request object/array instead of superglobals is not a real issue.
Regards,
Daniil Gentili.