2017 © Pedro Peláez
 

library think-worker

workerman extend for thinkphp5

image

5ini99/think-worker

workerman extend for thinkphp5

  • Tuesday, December 27, 2016
  • by 5ini99
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 23 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ThinkPHP 5.0 Workerman 扩展

安装

composer require 5ini99/think-worker:dev-master, (*1)

使用方法

首先创建控制器类并继承 think\worker\Server,然后设置属性和添加回调方法, (*2)

namespace app\index\controller;

use think\worker\Server;

class Worker extends Server
{
    protected $socket = 'http://0.0.0.0:2346';

    public function onMessage($connection,$data)
    {
        $connection->send(json_encode($data));
    }
}

支持workerman所有的回调方法定义(回调方法必须是public类型), (*3)

在应用根目录增加入口文件 server.php, (*4)

#!/usr/bin/env php
<?php
define('APP_PATH', __DIR__ . '/application/');

define('BIND_MODULE','index/Worker');

// 加载框架引导文件
require __DIR__ . '/thinkphp/start.php';

在命令行启动服务端, (*5)

php server.php start

linux下面可以支持下面指令, (*6)

php server.php start|stop|status|restart|reload

在浏览器中进行客户端测试 http://127.0.0.1:2346/?id=1, (*7)

The Versions

27/12 2016

dev-master

9999999-dev

workerman extend for thinkphp5

  Sources   Download

Apache-2.0

The Requires

 

by xiaobo.sun