Giter VIP home page Giter VIP logo

think-worker's Introduction

ThinkPHP 5.0 Workerman 扩展

安装

composer require 5ini99/think-worker:dev-master

使用方法

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

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类型)

在应用根目录增加入口文件 server.php

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

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

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

在命令行启动服务端

php server.php start

linux下面可以支持下面指令

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

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

think-worker's People

Contributors

liu21st avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar xiaobo.sun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.