Open mouyong opened 2 years ago
I'm testing with Laravel Orchid admin, and it's working. But still testing and fixing the session.
Fixed in Symfony and Laravel.
good job. maybe we can close project laravel-octane-workerman。
Why create a lib for only 1 framework, when we can create one (Adapterman) that we can use with almost any framework or app.
Only one lib to maintain, for all the frameworks.
After more checking, work but not correctly. It's nothing about Adapterman-Workerman.
I'm now trying to fix it. From the Laravel side. Laravel session, don't use Symfony session that use the normal $_SESSION from PHP or Workerman.
So we'll need to add 2 lines of code for clean the session, in any new request.
From @493226876
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
How do you set up the session and auth in Laravel, will be a problem with any worker mode: adapterman, laravel-swoole, Octane, ....
You can't do that, in any worker mode:
namespace App\Http\Controllers;
class TestController extends Controller
{
protected $userId;
public function __construct()
{
// Wrong usage: Since the controller is only constructed once and then resident in memory, $userId will only be assigned once, and subsequent requests will be misread before requesting $userId
$this->userId = session('userId');
}
public function testAction()
{
// read $this->userId;
}
}
Corect:
namespace App\Http\Controllers;
class TestController extends Controller
{
protected function getUserId()
{
return session('userId');
}
public function testAction()
{
// call $this->getUserId() to read $userId
}
}
This week, I'll try with Shared Nothing mode, that for sure will work. But the performance will be in the middle of php-fpm and worker mode.
The problem is from the Laravel side. And we are talking with Laravel devs to clean the session and auth in each request, but from the Laravel side. We will release the solution.
Not in Symfony demo.
We are fixing it.