On 30 December 2023 09:59:07 GMT, Robert Landers <landers.rob...@gmail.com> 
wrote:
>For this to happen in PHP Core, there would need to be request objects
>instead of a global state.

Again, the representation as objects isn't a key requirement. Python's WSGI 
spec simply has a dictionary (read: associative array) of the environment based 
on CGI. The application might well turn that into a more powerful object, but 
standardisation of such wasn't considered a pre-requisite, and would actually 
have hampered ASGI, where not all events represent an HTTP request.

The key requirement is that you have some way of passing the current request 
and response around as scoped variables, not global state. That's essential for 
any kind of concurrent run-time (async, thread-aware, etc).

An event / subscriber model fits well with that: the local scope for each 
request is set up by an invocation of the callback with defined parameters and 
return value.

Funnily enough, the example of a worker script for FrankenPHP does both things: 
it sends each request to the same application "handle" callback, passing in the 
super-global arrays as parameters to be used as non-global state. 
https://frankenphp.dev/docs/worker/#custom-apps So really all I'm arguing is 
that a few more lines of that PHP example be moved into the C implementation, 
so that the user only needs to provide that inner callable, not the outer while 
loop.

Regards,

-- 
Rowan Tommins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to