2017 © Pedro Peláez
 

library swmen

Swoole + Lumen

image

icyboy/swmen

Swoole + Lumen

  • Tuesday, June 14, 2016
  • by icyboy
  • Repository
  • 1 Watchers
  • 2 Stars
  • 34 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 21 % Grown

The README.md

swmen

Swoole + Lumen, (*1)

Depends On

  • php >= 5.5.9
  • lumen >= 5.2.*
  • ext-swoole >= 1.8.5

Install

 composer install

由于Lumen不支持使用Http Kernel,所以你必须在App目录创建一个Application.php,内容如下, (*2)

<?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, (*3)

//替换如下内容
//$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, (*4)

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, (*5)

###gzip

 SWMEN_GZIP=1

level is in the range from 1 to 9, bigger is compress harder and use more CPU time., (*6)

 SWMEN_GZIP_MIN_LENGTH=1024

Sets the mINImum length of a response that will be gzipped., (*7)

###deal_with_public

Use this ONLY when developing, (*8)

 SWMEN_DEAL_WITH_PUBLIC=true

###Swoole

Eexample:, (*9)

 SWMEN_HOST=0.0.0.0

Default host is 0.0.0.0:8088, (*10)

See Swoole's document:, (*11)

简体中文, (*12)

English, (*13)

##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, (*14)

The Versions

14/06 2016

dev-master

9999999-dev

Swoole + Lumen

  Sources   Download

MIT

The Requires

 

lumen swoole

14/06 2016

1.1.4

1.1.4.0

Swoole + Lumen

  Sources   Download

MIT

The Requires

 

lumen swoole

13/06 2016

1.1.3

1.1.3.0

Swoole + Lumen

  Sources   Download

MIT

The Requires

 

lumen swoole

31/05 2016

1.1.2

1.1.2.0

Swoole + Lumen

  Sources   Download

MIT

The Requires

 

lumen swoole

31/05 2016

1.1.1

1.1.1.0

Swoole + Lumen

  Sources   Download

MIT

The Requires

 

lumen swoole

19/05 2016

1.1.0

1.1.0.0

Swoole + Lumen

  Sources   Download

MIT

The Requires

 

lumen swoole

19/05 2016

1.0.0

1.0.0.0

Swoole + Lumen

  Sources   Download

MIT

The Requires

 

lumen swoole