bulaohe/swoole

基于Swoole的高性能HTTP服务器。加快您的Laravel和Lumen应用程序速度。

6.0.2 2021-09-10 10:26 UTC

README

将Swoole集成到Laravel和Lumen 5.5,5.7,5.8,6.x

此包是对 huang-yi/laravel-swoole-http 的重写,感谢 黄一 coodeer@163.com

注意

您应该在自定义 ServiceProvider 的 register 方法中重置 Singleton 模式 Facades 类的实例,如下所示

  1. 在 register 函数中添加清除代码 Facade::clearResolvedInstance('your-service-alias-name');

  2. 添加配置 http.providers 您的服务提供者 App\Providers{YourProvider}::class,

启动命令

php artisan swoole:http --host=0.0.0.0 --port=9807 --pid_file=/tmp/swoole1.pid start/stop/reload/restart

php artisan swoole:http --host=0.0.0.0 --port=9808 --pid_file=/tmp/swoole2.pid start/stop/reload/restart

nginx 配置

server { listen 80; server_name your_server_name; root /var/www/logistics/public; index index.php;

location = /index.php {
    # Ensure that there is no such file named "not_exists" in your "public" directory.
    try_files /not_exists @swoole;
}

location / {
    try_files $uri $uri/ @swoole;
}

location @swoole {
    set $suffix "";

    if ($uri = /index.php) {
        set $suffix "/";
    }

    proxy_set_header Host $host;
    proxy_set_header SERVER_PORT $server_port;
    proxy_set_header REMOTE_ADDR $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    # IF https
    # proxy_set_header HTTPS "on";

    proxy_pass http://127.0.0.1:9807$suffix;
}

}