Download the PHP package zhanguangcheng/php-http-client without Composer

On this page you can find all versions of the php package zhanguangcheng/php-http-client. 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 php-http-client

HTTP client library for PHP

README.md | 中文 README.md

A simple and powerful HTTP client library for PHP.

Features

File Structure

Installation

Requirements

Basic Usage

Configuration

HttpClient contains many options that control how requests are executed, including retry, concurrency, proxy, authentication, cookie keep, etc. These options can be defined globally (apply to all requests) and per request (override any global options).

You can create a client with options using HttpClient::create($options), $options is global options.

or, combined with the getter and setter of the Options class:

Send a request with options:

Making Requests

Sending Different Methods

Query String Parameters

You can manually add them to the URL that will be added to the request, or you can define them as an associative array with the Options::QUERY option, which will be merged with the URL:

Sending Request Headers

You can define the request headers to be sent with the Options::HEADERS option:

Sending Request Body

Use the second parameter of the post(), put(), patch(), delete() methods to send the request body:

You can also use the Options::BODY option to define the request body to be sent:

When uploading data using the POST method, if you do not explicitly define the Content-Type request header, the Content-Type:application/x-www-form-urlencoded request header will be added by default. If you want to customize the request type, you can use the Options::CONTENT_TYPE option, for example using the JSON format:

Gzip Compression

If the zlib extension is installed, the request header Accept-Encoding: gzip will be sent by default. When getting the response content, if the server supports gzip compression and the response header contains Content-Encoding: gzip, the response content will be automatically decompressed.

You can also turn off gzip compression:

Redirects

By default, the HTTP client will track redirects when making requests, and track 5 redirects by default. Use the Options::MAX_REDIRECTS setting to configure this behavior:

Retry Failed Requests

Sometimes, requests fail due to network issues or temporary server errors. You can use the Options::MAX_RETRY option to automatically retry failed requests. By default, failed requests are retried up to 3 times, with a delay between retries of 1 second for the first retry; 3 seconds for the second retry; and 5 seconds for the third retry. The conditions for retrying are: request timeout or response status code is one of 423, 425, 429, 500, 502, 503, 504, 507 and 510.

User Authentication

HttpClient supports different authentication mechanisms. They can be defined globally in the configuration (apply to all requests) and per request (override any global authentication):

Request Proxy

HttpClient supports sending requests using HTTP proxies. They can be defined globally in the configuration (apply to all requests) and per request (override any global proxy):

Cookie Keep

Use the CookieJar class to keep the cookies in the response and send them in subsequent requests:

File Download

Use the download() method of HttpClient to download files, and you can use the Options::ON_PROGRESS option to monitor the download progress:

HTTPS Certificate Verification

Certificate download address: https://curl.haxx.se/docs/caextract.html

By default, the system's CA certificate is used, such as the curl.cainfo or openssl.cafile configuration in the php configuration file:

You can also use the Options::CAFILE option to specify the HTTPS certificate:

Close certificate verification (not recommended in production environment):

Concurrent Requests

Set the second parameter of HttpClient::create($options, $concurrency) to the number of concurrent requests, use the addRequest($method, $url, $options) method to add requests, and then use the send() method to send requests, the response array is in the same order as the request array. You can also use the Options::MAX_RETRY option to set the failed requests when retrying concurrent requests.

Processing Responses

All responses returned by HttpClient are objects of type Response and provide the following methods:

Testing

Run the following command to run the tests:

100% code coverage

References


All versions of php-http-client with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-curl Version *
ext-json Version *
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 zhanguangcheng/php-http-client contains the following files

Loading the files please wait ....