PHP code example of xiaodi / xiaodi-worker

1. Go to this page and download the library: Download xiaodi/xiaodi-worker 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/ */

    

xiaodi / xiaodi-worker example snippets



namespace app\Worker;

use think\worker\Server;

class Http extends Server
{
    protected $socket = 'http://0.0.0.0:55555';

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




return [
  'Http' => '\app\Worker\Http'
];