GithubHelp home page GithubHelp logo

http's Introduction

FastD HTTP Server and Client

Building Support Swoole Support PSR7 Latest Stable Version Total Downloads Latest Unstable Version License

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

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

要求

  • php >= 5.6

安装

composer require "fastd/http" -vvv

文档

文档

使用

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

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

获取 pathinfo
use FastD\Http\ServerRequest;

$request = ServerRequest::createServerRequestFromGlobals();

$request->getUri()->getPath();
Swoole Http 服务器
$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();
cURL 请求

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

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

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

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

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

License MIT

http's People

Contributors

janhuang avatar runnerlee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.