expressif / http
使用 expressif 流实现的 http 库
0.0.1-rc3
2015-01-28 21:06 UTC
Requires
- ext-http: >=2.1.0
- expressif/socket: 0.0.5
This package is not auto-updated.
Last update: 2024-09-28 16:58:50 UTC
README
包含 pecl_http 和 libevent 之间的 http 绑定,用于创建快速的 Web 服务器。
需求
此库使用 expressif/stream 和 http 模块
- PHP 5.6+
- libevent
- pecl_http
如果您在 Windows 上(出于开发和测试目的),可以直接 安装预构建库。
注意:如果您计划在多核服务器上使用此库,应考虑 expressif/cluster。
使用方法
<?php require 'vendor/autoload.php'; use Expressif\Http\Server; $endpoint = '127.0.0.1:1337'; echo "Serving HTTP at http://$endpoint\n"; $http = new Server('tcp://' . $endpoint); $http->on('request', function($req, $res) { $res->writeHead(200, ['Content-Type' => 'text/plain']); $res->end('Hello world'); });