athena-oss/php-fluent-http-client

PHP Fluent Http Client

v0.9.0 2017-05-02 12:52 UTC

This package is not auto-updated.

Last update: 2024-09-27 22:28:18 UTC


README

Build Status

PHP Fluent Http Client 是一个用于通过流畅的 API 处理 HTTP 请求和响应的库。

如何安装?

您有两个选项将此库用于您的项目

"require": {
    "athena-oss/php-fluent-http-client": "0.7.0",
 }

示例

带有对响应断言的 GET 方法

  • 头部值
  • 内容类型
  • 状态码
$responseJson = (new HttpClient())->get('http://example.com')
            ->withHeader('name', 'value')
            ->withProxy('http://myproxy.com', 3128)
            ->then()
            ->assertThat()
            ->headerValueIsEqual('expected_header', 'expected_value')
            ->responseIsJson()
            ->statusCodeIs(200)
            ->retrieve()
            ->fromJson();

带有授权和状态码断言的 POST 方法

$responseString = (new HttpClient())->put('http://example.com')
            ->withUserAgent('my_user_agent_string')
            ->withDigestAuth('myusername', 'mypassword')
            ->withProxy('http://myproxy', 1234)
            ->withBody('my content', 'my content type')
            ->then()
            ->assertThat()
            ->statusCodeIs(201)
            ->retrieve()
            ->fromString();

贡献

请查看我们在 CONTRIBUTING.md 中的贡献指南。

版本控制

使用 GitHub 的发布功能管理发布。我们使用 语义版本控制 来管理所有发布。对代码库所做的每次更改都将记录在发布说明中(除非是清理和重构)。

许可证

根据 Apache License Version 2.0 (APLv2) 许可。