Home > PHP Framework > Workerman > body text

How to access workererman in php

Release: 2019-12-23 16:25:14
Original
3388 people have browsed it

How to access workererman in php

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 &#39;./Workerman/Autoloader.php&#39;;

// 创建一个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();
Copy after login

2. Start the service similar to the following picture:

php start.php start -d

How to access workererman in php

3. View the workerman running status similar to the following interface:

php start.php status

How to access workererman in php

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!