amphp/http-server-form-parser
最新稳定版本:v2.0.0
Composer 安装命令:
composer require amphp/http-server-form-parser
包简介
An HTTP server plugin that simplifies form data handling. Effortlessly parse incoming form submissions and extracting its data.
README 文档
README
This package is an add-on to amphp/http-server, which allows parsing request bodies as forms in either x-www-form-urlencoded or multipart/form-data format.
Installation
This package can be installed as a Composer dependency.
composer require amphp/http-server-form-parser
Usage
Basic usage works by calling Form::fromRequest($request), which will buffer the request body and parse it. This method may be called multiple times, so both a middleware and request handler may access the form body.
use Amp\Http\Server\FormParser\Form; use Amp\Http\Server\Request; use Amp\Http\Server\RequestHandler\ClosureRequestHandler; use Amp\Http\Server\Response; use Amp\Http\Status; $requestHandler = new ClosureRequestHandler(function (Request $request) { $form = Form::fromRequest($request); return new Response(Status::OK, [ "content-type" => "text/plain; charset=utf-8" ], $form->getValue("text") ?? "Hello, World!"); });
There's also an advanced streaming parser included, StreamingFormParser, which can be used to stream uploaded files to disk or other locations.
统计信息
- 总下载量: 83.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 1
- 依赖项目数: 15
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-14