Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: initStateless() method #54

Open
vanodevium opened this issue Dec 13, 2023 · 3 comments
Open

Feature request: initStateless() method #54

vanodevium opened this issue Dec 13, 2023 · 3 comments

Comments

@vanodevium
Copy link
Contributor

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();
@vanodevium
Copy link
Contributor Author

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!

@joanhey
Copy link
Owner

joanhey commented Dec 14, 2023

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 php/php-src#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.

@vanodevium
Copy link
Contributor Author

@joanhey

I am very grateful to you for such a detailed and understandable answer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants