Feature request: initStateless() method
When my laravel app doesn't use sessions at all, or it's set to a non-file engine, I don't want to rewrite php functions.
So it's just another adapterman initialization method that won't check the php.ini
Something like:
Adapterman::initStateless();
Additional Information.
I already tried to test locally and the tests fail. It all depends on two functions (at least).
- http_response_code
- setcookie
Without overriding these functions, the tests fail and do not want to work at all.
So I have a huge request for you: could you please explain why to override the workerman's \Protocols\Http::class, if it - as far as I know - supports sessions and cookies perfectly.
Thank you very much in advance!
Hi @vanodevium
Before Adapterman was using the same Http::class from Workerman v3.
But from Workerman v4, the class need to change to accommodate threading events systems (swoole, swow, revolt, ...) and maintain a uniform interface.
With unix event, pecl libevent and pecl libev we use forks, so any fork work independent and can change any global constant or variable without affect the others. And that is impossible with a threading event system.
Adapterman can't work with any threading event as master loop. But can be used it inside the apps.
PHP is using the superglobals, to initiate any request. And that is incompatible with a threading system. As any change in these global values will affect the others threads. For that they need to encapsulate that values inside classes (Request and Response).
Workerman v4 don't use any superglobal, so we need to create another Http::class as we need it to access $_GET, $_POST, .... in any normal PHP app.
The near future
Actually Adapterman override the header functions, that don't work with CLI. But later we need an spiral of changes with any function that use the headers: setcookie, sessions, ....
After checking the PHP C source, with a very small change, the headers can work in CLI also and we can remove all the override functions and php code in Adapterman (and other CLI apps).
I created the issue https://github.com/php/php-src/issues/12304 It's accepted as a feature, but I think that I'll need to move it in the php mail-list.
After this small change, we can use any PHP app without overrides or extra php code. And any code using setcookie or sessions will work without any problem.
@joanhey
I am very grateful to you for such a detailed and understandable answer!