workerman is a high-performance PHP socket server framework. Workerman is based on PHP multi-process and libevent event polling library. PHP developers only need to implement one or two interfaces to develop their own Network applications, such as Rpc services, chat room servers, mobile game servers, etc.
Installation
Download and unzip it
Use workererman in php:
1. Create a new file start.php
<?php use Workerman\Worker; require_once './Workerman/Autoloader.php'; // 创建一个Worker监听2346端口,使用websocket协议通讯 $ws_worker = new Worker("websocket://0.0.0.0:2346"); // 启动4个进程对外提供服务 $ws_worker->count = 4; // 当收到客户端发来的数据后返回hello $data给客户端 $ws_worker->onMessage = function($connection, $data) { // 向客户端发送hello $data $connection->send('hello ' . $data); }; // 运行 Worker::runAll();
2. Start the service similar to the following picture:
php start.php start -d
3. View the workerman running status similar to the following interface:
php start.php status
Recommended: workerman php tutorial
The above is the detailed content of How to access workererman in php. For more information, please follow other related articles on the PHP Chinese website!