jimdo / http
此包已被废弃,不再维护。没有建议替代包。
Http客户端库
v0.1.7
2017-05-26 12:58 UTC
Requires (Dev)
- phpunit/phpunit: ^5.4
README
php-http-lib
此仓库是一个包含http客户端(响应、请求和会话)的库。
Makefile
库代码提供了一个Makefile文件
$ make help
bootstrap Install composer
update Update composer packages
tests Execute test suite
下载
$ https://packagist.org.cn/packages/jimdo/http
$ composer require jimdo/http
开发设置
# Clone the repository
$ git clone git@github.com:Jimdo/php-http-lib.git
# Install composer and project dependencies
$ make bootstrap
# Requirements for test-driven
$ (xDebug) phpbrew ext install xdebug
请求对象中的有用方法
- __construct(queryParams, formData, sessionData) - 构造函数用于将查询参数和表单数据作为数组填充。第三个是会话对象。
- getQueryParams() - 如果有可用,则返回查询参数数组
- getFormData() - 返回表单信息数组
- getSessionData() - 返回会话数据数组
响应对象中的有用方法
- addBody() - 将html代码附加到单个字符串以正确格式化主体
- addHeader() - 向响应头添加一个头部
- render() - 将头部和主体渲染成正确的html输出代码
Session
对象
Session对象通过魔法属性和方法进行处理。
- 通过__construct设置属性或通过会话对象定义属性
(example)
1. $session = new Session(["foo" => "bar"]);
2. $session->foo = "bar";
- 获取属性
(example)
$session = new Session(["foo" => "bar"]);
$data = $session->foo;