icyboy / swmen
Swoole + Lumen
1.1.4
2016-06-14 03:26 UTC
Requires
- php: >=5.5.9
- laravel/lumen-framework: 5.2.*
- ramsey/uuid: ~2.8
This package is not auto-updated.
Last update: 2024-12-13 20:19:06 UTC
README
#swmen
Swoole + Lumen
Depends On
- php >= 5.5.9
- lumen >= 5.2.*
- ext-swoole >= 1.8.5
##Install
composer install
由于Lumen不支持使用Http Kernel,所以你必须在App目录创建一个Application.php,内容如下
<?php /** * Created by PhpStorm. * User: Icyboy <icyboy@me.com> * Date: 2016/5/19 * Time: 11:07 */ namespace App; class Application extends \Laravel\Lumen\Application { public function getMiddleware() { return $this->middleware; } public function callTerminableMiddleware($response) { parent::callTerminableMiddleware($response); } }
然后修改bootstrap目录下的app.php
//替换如下内容 //$app = new Laravel\Lumen\Application( // realpath(__DIR__.'/../') //); $app = new App\Application( realpath(__DIR__.'/../') );
##Usage
vendor/bin/swmen start | stop | reload | restart | quit
##Config
In .env , use SWMEN_* to config swoole server. For example
SWMEN_REACTOR_NUM=1
SWMEN_WORKER_NUM=4
SWMEN_BACKLOG=128
SWMEN_DISPATCH_MODE=1
###pid_file
SWMEN_PID_FILE=/path/to/swmen.pid
default is at /lumen/storage/logs/swmen.pid
###gzip
SWMEN_GZIP=1
level is in the range from 1 to 9, bigger is compress harder and use more CPU time.
SWMEN_GZIP_MIN_LENGTH=1024
Sets the mINImum length of a response that will be gzipped.
###deal_with_public
Use this ONLY when developing
SWMEN_DEAL_WITH_PUBLIC=true
###Swoole
Eexample:
SWMEN_HOST=0.0.0.0
Default host is 0.0.0.0:8088
See Swoole's document:
##Work with nginx
server { listen 80; server_name localhost; root /path/to/swmen/public; location ~ \.(png|jpeg|jpg|gif|css|js)$ { break; } location / { proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_pass http://127.0.0.1:8088; } }
#License MIT