Download the PHP package drewlabs/curl-client without Composer

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

cURL Client

This project tends to implements an Object oriented PHP cURL client and provides a PSR18 implementation based on the cURL client object.

Installation

Recommended way to install the library is by using PHP package manager composer running the command below:

composer require drewlabs/curl-client

Usage

The library comes with 2 cURL client, the 1st being an object oriented cURL class and PSR18 compatible client based on PHP cURL library.

OOP cURL client

To create a new instance of the client, use the class constructor:

This will create a new client instance and initialize a new curl session. Developpers can pass a base url to the client instance to define the host server url:

Curl Options

cURL options allow developpers to customize cURL request sent to the application server. Using Client::setOption() or Client::setOptions() for array like options, developpers can customize cURL requests being sent to the server.

In order to pass cURL options as array, we use the setOptions() array method:

Sending cURL request

The client provides developpers with Client::send() method to send HTTP request to server:

Sometimes you may have constructed the curl request and wish to simply execute the curl request. To do so the client mimic the curl exec() method by providing Client::exec() method for sending request to server.

The client comes with some helper method for basic curl HTTP options like, CURLOPT_URL, \CURLOPT_SSL_VERIFYPEER, \CURLOPT_HTTP_VERSION etc... Below is a brief API definition for most common use cases:

Client::setRequestUri(string $url) - Set the request URI Client::setRequestMethod(string $method) - Set the request method Client::setProtocolVersion(string $version) - Set the HTTP protocol version Client::withAutoReferer() - Automatically set the auto referer header where it follows redirect Client::followLocation() - Follows any location redirect unless \CURLOPT_MAXREDIR is sets. Client::maxRedirects(int $n) - The number of redirect to be followed by the cURL client Client::proxy($proxy, $port = null, $username = null, $password = null) - Defines an HTTP proxy through which the request is forwarded. Client::setUserAgent($user_agent) - Defines the request user agent Client::timeout(int $milliseconds) - Timeout the request for a given milliseconds Client::verifyHost() - Make sure the cURL client validate host domain and SSL certificate

Note By default the cURL connection is closed the PHP runtime when the object is destructed. If developper which to close the curl session, or reset cURL parameters, the instance provides with close() and release() method for each specific case:


All versions of curl-client with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
ext-curl 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 drewlabs/curl-client contains the following files

Loading the files please wait ....