search
HomePHP FrameworkWorkermanHow to access workerman

How to access workerman

Dec 24, 2019 pm 02:38 PM
workerman

How to access workerman

You need to create an entry file to access Workerman:

Like the PHP application under nginx PHP-FPM, the application in WorkerMan also needs an entry file, entry There is no requirement for the file name, and this entry file is run in PHP Cli mode. Recommended: workerman tutorial

The entry file contains the code related to creating a listening process, such as the following code snippet developed based on Worker

test.php

<?php
use Workerman\Worker;
require_once __DIR__ . &#39;/Workerman/Autoloader.php&#39;;

// 创建一个Worker监听2345端口,使用http协议通讯
$http_worker = new Worker("http://0.0.0.0:2345");

// 启动4个进程对外提供服务
$http_worker->count = 4;

// 接收到浏览器发送的数据时回复hello world给浏览器
$http_worker->onMessage = function($connection, $data)
{
    // 向浏览器发送hello world
    $connection->send(&#39;hello world&#39;);
};

Worker::runAll();


The above is the detailed content of How to access workerman. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.