Download the PHP package flc/http without Composer

On this page you can find all versions of the php package flc/http. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package http

PHP HTTP 客户端

该扩展基于 Laravel 的 illuminate/http 扩展进行简化独立而得,核心源码更多为官方源码。

安装

非稳定版,请勿用于生产

使用

使用文档,拷贝官方的,:sweat_smile: :sweat_smile:

创建请求

你可以通过 getpostputpatchdelete 方法来创建请求。首先,让我们先看一下如何发出一个基础的 GET 请求:

get 方法返回一个 Flc\Http\Response 的实例,该实例提供了大量的方法来检查请求的响应:

Flc\Http\Response 对象同样实现了 PHP 的 ArrayAccess 接口,这代表着你可以直接访问响应的 JSON 数据。

请求数据

大多数情况下,POSTPUTPATCH 携带着额外的请求数据是相当常见的。所以,这些方法的第二个参数接受一个包含着请求数据的数组。默认情况下,这些数据会使用 application/json 类型随请求发送。

发送 URL 编码的请求

如果你希望使用 application/x-www-form-urlencoded 作为请求的数据类型,你可以在创建请求前调用 asForm 方法:

发送 Multipart 请求

如果你希望将文件作为 Multipart 请求发送,你应该在创建请求前调用 attach 方法。该方法接受文件的标识符(相当于 HTML Input 的 name 属性)以及其内容。你也可以在第三个参数传入自定义的文件名称,这不是必须的。

除了传递文件的原始内容,你也可以传递 Stream 流数据:

请求头

你可以通过 withHeaders 方法添加请求头。该方法接受一个数组格式的键值对。

认证

你可以使用 withBasicAuthwithDigestAuth 方法来分别指定使用 basic 或是 digest 认证方式:

Bearer Token(Token 令牌)

如果你想要为你的请求快速添加 Authorization Token 令牌请求头,你可以使用 withToken 方法:

重试

如果你希望你的 HTTP 客户端在发生错误时自动重新发送请求,你可以使用 retry 方法。该方法接受两个参数:重新尝试次数以及重试等待时间(毫秒):

如果所有的请求都失败了,Flc\Http\RequestException 异常将会被抛出。

错误处理

跟 Guzzle 的默认行为不同,Laravel HTTP 客户端并不会在客户端或服务端错误时抛出异常(400500 状态码)。你可以通过 successfulclientError 或是 serverError 方法来判断是否发生错误:

抛出异常

如果你希望请求在发生客户端或服务端错误时抛出 Flc\Http\RequestException 异常,你可以在请求实例上调用 throw 方法:

Flc\Http\RequestException 实例拥有一个 $response 公共属性,该属性允许你检查返回的响应。

如果没有发生错误,throw 方法将返回响应实例,你可以在其上进行其他操作:

LICENSE

MIT


All versions of http with dependencies

PHP Build Version
Package Version
Requires guzzlehttp/guzzle Version ^6.5.5|^7.0.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package flc/http contains the following files

Loading the files please wait ....