A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/fastdlabs/http below:

fastdlabs/http: Support Swoole Implement PSR7

FastD HTTP Server and Client

简单的 Http 协议组件, 用于解析 Http 请求信息, 实现 PSR-7 标准, 支持 Swoole 扩展.

以上库可以满足大部分 HTTP 请求处理相关工作, 支持 Swoole 处理, 具体请看项目Swoole

composer require "fastd/http" -vvv

文档

HTTP 组件封装了常用的服务端解释,客户端请求,并且友好集成 Swoole Http Server 解析,实现PSR-7。

HTTP 组件没有对 Session 进行封装, 如果想在项目中支持 Session, 可以通过 Session 组件进行扩展.

use FastD\Http\ServerRequest;

$request = ServerRequest::createServerRequestFromGlobals();

$request->getUri()->getPath();
$http = new swoole_http_server("127.0.0.1", 9501);

$http->on('request', function ($request, $response) {
    $server = SwooleServerRequest::createServerRequestFromSwoole($request);
    $response->end($server->getUri()->getPath());
});

$http->start();

Request 对象内部封装了 cURL 请求, 可以直接通过方法调用

$request = new Request('GET', 'https://api.github.com/');

$request->setReferrer('http://example.com/');

$response = $request->send(); // FastD\Http\Response

响应内容会通过 Response 对象返回。

非常欢迎感兴趣,愿意参与其中,共同打造更好PHP生态,Swoole生态的开发者。

如果你乐于此,却又不知如何开始,可以试试下面这些事情:

如果你在使用中遇到问题,请联系: bboyjanhuang@gmail.com. 微博: 编码侠


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4