aura/web
Composer 安装命令:
composer require aura/web
包简介
Provides web Request and Response objects for use by web controllers and actions. These are representations of the PHP web environment, not HTTP request and response objects proper.
README 文档
README
Provides web Request and Response objects for use by web controllers and actions. These are representations of the PHP web environment, not HTTP request and response objects proper.
Foreword
Installation
This library requires PHP 5.3 or later; we recommend using the latest available version of PHP as a matter of principle. It has no userland dependencies.
It is installable and autoloadable via Composer as aura/web.
Alternatively, download a release or clone this repository, then require or include its autoload.php file.
Quality
To run the unit tests at the command line, issue composer install and then ./vendor/bin/phpunit at the package root. This requires Composer to be available as composer.
This library attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request.
Community
To ask questions, provide feedback, or otherwise communicate with the Aura community, please join our Google Group, follow @auraphp on Twitter, or chat with us on #auraphp on Freenode.
Getting Started
Instantiation
First, instantiate a WebFactory object, then use it to create Request and Response objects.
<?php use Aura\Web\WebFactory; $web_factory = new WebFactory($GLOBALS); $request = $web_factory->newRequest(); $response = $web_factory->newResponse(); ?>
Note that if jit-globals is turned on, merely passing $GLOBALS will not
work properly. In this case, use compact() to pass the needed values. For
example:
<?php use Aura\Web\WebFactory; $web_factory = new WebFactory(array( '_ENV' => $_ENV, '_GET' => $_GET, '_POST' => $_POST, '_COOKIE' => $_COOKIE, '_SERVER' => $_SERVER )); $request = $web_factory->newRequest(); $response = $web_factory->newResponse(); ?>
Request and Response Objects
Because each object contains so much functionality, we have split up the documentation into a Request page and a Response page.
By way of overview, the Request object has these sub-objects ...
- $request->cookies for $_COOKIES
- $request->env for $_ENV
- $request->files for $_FILES
- $request->post for $_POST
- $request->query for $_GET
- $request->server for $_SERVER
- $request->client for the client making the request
- $request->content for the raw body of the request
- $request->headers for the request headers
- $request->method for the request method
- $request->params for path-info parameters
- $request->url for the request URL
... and the Response object has these sub-objects:
- $response->status for the status code, status phrase, and HTTP version
- $response->headers for non-cookie headers
- $response->cookies for cookie headers
- $response->content for describing the response content, and for convenience methods related to content type, charset, disposition, and filename
- $response->cache for convenience methods related to cache headers
- $response->redirect for convenience methods related to Location and Status
Once you have built a Response you can send it with any HTTP mechanism you prefer, including plain PHP.
Be sure to read the Request and Response pages for more detailed information.
aura/web 适用场景与选型建议
aura/web 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 566.03k 次下载、GitHub Stars 达 82, 最近一次更新时间为 2012 年 01 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「response」 「request」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aura/web 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aura/web 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aura/web 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
HTTP request logger middleware for Laravel
Class to generate a standard structure for api json responses
Adds request-parameter validation to the SLIM 3.x PHP framework
A simple HTTP application builder using PSR-15 HTTP Server Request Handler and Middleware.
Marussia request
Speed up a Laravel application by caching the entire response additions
统计信息
- 总下载量: 566.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 83
- 点击次数: 34
- 依赖项目数: 9
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2012-01-20