walkor / workerman

An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols.
http://www.workerman.net
MIT License
11.06k stars 2.26k forks source link

[Feature] Use almost any PHP fw or app with Workerman #824

Open joanhey opened 1 year ago

joanhey commented 1 year ago

Hi Walkor,

I was using a lib internally for more than 2 years, for my legacy apps to run with Workerman v3.5. https://github.com/joanhey/AdapterMan

This week I tested with frameworks, and It's working perfectly, without touch 1 line of code in the fw or app.

We only need an small change to the Front Controller and PHP 8 as minimum.

Tested with:

Now I'm creating PRs in the Techempower benchmark. https://github.com/TechEmpower/FrameworkBenchmarks/pull/7627 https://github.com/TechEmpower/FrameworkBenchmarks/pull/7626 Later I will push Slim and more fws.

I think that this lib will be useful for more people.

If time permits, I'll try to add documentation and upgrade to Workerman v4

walkor commented 1 year ago

We need to add the protocol to Workerman v4.2 and/or 5

which protocol?

joanhey commented 1 year ago

The new Http protocol from v4, it's using Request and Response classes. Never populate or read the Super Globals Variables from PHP ($_GET, $_POST, $_SESSION, ...), necessary to use with any php app. I can try to do it with these classes, but I think it's easier to have a new protocol like the Http from v3. We can start with the same in v3, to improve it later. Starting by reusing the new SessionHandler class.

493226876 commented 1 year ago

I have a very serious problem with the token of larravel in use. My logins in other places are consistent, which means that the token will not change, and my authentication session authentication will not be secure

493226876 commented 1 year ago

After using the worker man acceleration task larravel project, I can directly log in to other computers after logging in to one computer, such as the session global sharing. What should I do

joanhey commented 1 year ago

@493226876 please use the adapterman issues

walkor commented 1 year ago

@joanhey

Workerman removed the super global variables filling since 4.0 because the super global variables cannot be used in asynchronous environment and co scheduling environment.

It is easy to fill in super global variables in version 4.0 which codes like below.

$worker->onMessage = function($connection, $request){
    $_GET = $request->get();
    $_POST = $request->post();
    $_SESSION = $request->session()->all();
    $connection->send(run());
};

Workerman should not have two similar http protocols, which will confuse developers. Except AdapterMan, other workerman projects do not need super global variables, so it is unwise to add an another similar http protocol to the workerman. I prefer that AdapterMan is compatible with the http protocol of workerman 4.0, or AdapterMan uses its own http protocol.

493226876 commented 1 year ago

How to use it? I log in to sesssionID on different computers all the time

493226876 commented 1 year ago

The sesssionID printed by my browser refreshed in different environments frequently appears the same as that of other networks

joanhey commented 1 year ago

@493226876 Please use the issues in Adapterman

Precisely the problem is that Laravel is the only fw, that don't use the $_SESSION. We are talking with Laravel devs, to clean the session in each request, but from the Laravel side, it's not a problem from Adapterman or Workerman. But we will release the solution. This week I'll try it with the Shared Nothing mode, that for sure will work, but the performance will be in the middle of php-fpm and worker mode.

493226876 commented 1 year ago

OK, thank you for telling me. I always thought that it was a problem where I set up the session. The session has always been repeated. It was originally a mechanism problem. If you have any trouble, please let me know. Thank you

Message ID: @.***>

493226876 commented 1 year ago

OK, thank you for telling me. I always thought that it was a problem where I set up the session. The session has always been repeated. It was originally a mechanism problem. If you have any trouble, please let me know. Thank you

joanhey commented 1 year ago

Please use the isssues in Adapterman. And I'll talk with you, not here.

493226876 commented 1 year ago

Ok, I will follow your latest news, look forward to the new release, and worship the boss!

lizhichao commented 1 year ago

This is powerful, simple and easy to use

493226876 commented 1 year ago

@joanhey Hello, is the Shared Nothing mode available

joanhey commented 1 year ago

No, and still not working like Shared Nothing for now.

joanhey commented 1 year ago

Release v0.6 Use Workerman v4.1.x and recipe for ThinkPHP.

Still we need a Laravel dev, to help with close the session when finish each request. (Laravel don't use $_SESSION)

493226876 commented 1 year ago

Boss, do you mean that Laraver still hasn't solved the problem of closing the session every time a request is made

寻找¤真爱 @.***

 

------------------ 原始邮件 ------------------ 发件人: "walkor/workerman" @.>; 发送时间: 2023年3月13日(星期一) 晚上11:24 @.>; @.**@.>; 主题: Re: [walkor/workerman] [Feature] Use almost any PHP fw or app with Workerman (Issue #824)

Release v0.6 Use Workerman v4.1.x and recipe for ThinkPHP.

Still we need a Laravel dev, to help with close the session when finish each request. (Laravel don't use $_SESSION)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

jhdxr commented 1 year ago

Laraver still hasn't solved the problem of closing the session every time a request is made

@493226876 There is a tryGcSessions, and here is an example from AdapterMan. You can try to modify your own start.php.

And the most important thing, YOU SHOULD USE ADAPTERMAN ISSUES to ask/discuss this. 你应该在ADAPTERMAN ISSUES咨询/讨论相关的问题

Still we need a Laravel dev, to help with close the session when finish each request. (Laravel don't use $_SESSION)

@joanhey , I just commented on this several days ago (https://github.com/joanhey/AdapterMan/issues/5#issuecomment-1502754308), actually laravel do have a way to clean up after each request, with the help of Laravel Octane.

ashokkumar88 commented 1 year ago

Trying now with Codeigniter4

@joanhey Is it working with Codeigniter 4?