PHP code example of evan-li / think-gateway

1. Go to this page and download the library: Download evan-li/think-gateway library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

evan-li / think-gateway example snippets


    
    namespace app\worker\controller;

    use think\gateway\Server;

    class Starter extends Server
    {

    }
    

class Starter extends Server
{

    protected $businessEventHandler = 'app\worker\util\EventsHandler';

}


namespace app\worker\util;

use think\gateway\Events;

class EventsHandler extends Events
{

    public static function processMessage($client_id, $message)
    {
        parent::processMessage($client_id, $message); // do some thing
    }
}
    
// 启动文件说明
start_register.php    注册服务启动文件
start_gateway.php     gateway(网关)服务启动文件
start_business.php    业务服务启动文件
sh
       php ./start.php start