Home > PHP Framework > Workerman > body text

Workerman's entry file

(*-*)浩
Release: 2021-02-01 12:08:52
Original
3010 people have browsed it

Workerman's entry file

WorkerMan entry file

is the same as the PHP application under nginx PHP-FPM, the application in WorkerMan An entry file is also required. There is no requirement for the entry file name, and this entry file is run in PHP Cli mode. (Recommended study: 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();
Copy after login

The above is the detailed content of Workerman's entry file. 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!