public function createServer(array $config)
    {
        // Mark server mode
        define('SERVER_MODE', 'swoole');

        $this->config = $config + [
            'host' => '0.0.0.0',
            'port' => '8000',
            'task_worker_num' => 0,
            'enable_websocket'=> false
        ];

        // Start websocket or http server
        if ( empty($config['enable_websocket']) ) {
            $this->server = new \Swoole\Http\Server($this->config['host'], $this->config['port']);
        } else {
            $this->config['open_http_protocol'] = true;
            $this->server = new \Swoole\WebSocket\Server($config['host'], $config['port'], SWOOLE_PROCESS, SWOOLE_SOCK_TCP);
        }

        $this->server->set($this->config);

        // Show welcome finger
        $this->printServerFinger();

        return $this;
    }
public function createServer(array $config)
    {
        // Mark server mode
        define('SERVER_MODE', 'swoole');

        $this->config = $config + [
            'host' => '0.0.0.0',
            'port' => '8000',
            'task_worker_num' => 0,
            'enable_websocket'=> false
        ];

        // Start websocket or http server
        if ( empty($config['enable_websocket']) ) {
            $this->server = new \Swoole\Http\Server($this->config['host'], $this->config['port']);
        } else {
            $this->config['open_http_protocol'] = true;
            $this->server = new \Swoole\WebSocket\Server($config['host'], $config['port'], SWOOLE_PROCESS, SWOOLE_SOCK_TCP);
        }

        $this->server->set($this->config);

        // Show welcome finger
        $this->printServerFinger();

        return $this;
    }
public function createServer ( array $ config ) { // Mark server mode define ( 'SERVER_MODE' , 'swoole' ) ; $ this -> config = $ config + [ 'host' => '0.0.0.0' , 'port' => '8000' , 'task_worker_num' => 0 , 'enable_websocket' => false ] ; // Start websocket or http server if ( empty ( $ config [ 'enable_websocket' ] ) ) { $ this -> server = new \ Swoole \ Http \ Server ( $ this -> config [ 'host' ] , $ this -> config [ 'port' ] ) ; } else { $ this -> config [ 'open_http_protocol' ] = true ; $ this -> server = new \ Swoole \ WebSocket \ Server ( $ config [ 'host' ] , $ config [ 'port' ] , SWOOLE_PROCESS , SWOOLE_SOCK_TCP ) ; } $ this -> server -> set ( $ this -> config ) ; // Show welcome finger $ this -> printServerFinger ( ) ; return $ this ; }
Create a swoole server

@param  array $config server config
@return \Swoole\Http\Server
Create a swoole server