icyxp / swmen by icyboy

Swoole + Lumen
45
2
2
Package Data
Maintainer Username: icyboy
Maintainer Contact: icyboy@me.com (icyboy)
Package Create Date: 2016-05-19
Package Last Update: 2016-06-14
Language: PHP
License: MIT
Last Refreshed: 2024-11-15 15:11:25
Package Statistics
Total Downloads: 45
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 2
Total Forks: 1
Total Open Issues: 0

#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:

简体中文

English

##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