spoom-php / http
Spoom 框架的 HTTP 支持
dev-development
2018-07-01 16:34 UTC
Requires
- php: ^7.1.0
- spoom-php/composer: ^1.0.0
- spoom-php/core: @dev
Requires (Dev)
- phpmd/phpmd: @stable
- phpunit/phpunit: ^6.0
- squizlabs/php_codesniffer: @stable
This package is auto-updated.
Last update: 2024-09-12 09:34:20 UTC
README
Spoom 框架
Spoom 是一组协作库(扩展),您可以使用它“构建”满足您需求的框架。
关于 Http
Spoom 框架的默认 HTTP 处理器。提供统一接口(MessageInterface
)用于请求和响应,Application
用于处理 HTTP 调用以及其他 HTTP 相关辅助工具,如:Helper\UriInterface
、Converter\Query
和 Converter\Multipart
安装
使用以下命令安装最新版本
$ composer require spoom-php/http
使用方法
以下是一个用于处理 HTTP 请求的 'hello world' 示例
<?php require __DIR__ . '/vendor/autoload.php'; use Spoom\Http; use Spoom\Http\Message; use Spoom\Core\Helper\Stream; use Spoom\Core\File; // create HTTP application $spoom = new Http\Application( // used environment's name Http\Application::ENVIRONMENT_DEVELOPMENT, // default localization 'en', // root directory of the application new File( __DIR__ ) ); // run the application with the default request object $request = Http\Application::getRequest(); $response = $spoom( $request, function( $input, $request, $uri ) { // handle stuffs.. // create response body and write a nice message to it $stream = new Stream( 'php://memory', Stream::MODE_RW ); $stream->write( '<h1>Hello World!</h1>' ); // create a response for the request return new Message\Response( $stream->seek( 0 ) ); }); // send the response as a result for PHP request Http\Application::response( $response, $request );
许可证
Spoom 框架是开源软件,根据 MIT 许可证 许可。