Download the PHP package lucinda/requester without Composer

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

Lucinda URL Requester

Table of contents:

About

This API is a light weight cURL wrapper aimed at completely hiding chaotic native library underneath through a full featured OOP layer that is easy and logical to work with. It is built as an antithesis of Guzzle, the "industry standard" today, by being:

Library is 99% unit tested (some areas of cURL functionality have zero documentation), fully PSR-4 compliant, only requiring PHP8.1+ interpreter and cURL extension. For installation you just need to write this in console:

Then use one of main classes provided:

Each of above classes branches through its methods to deeper classes that become relevant depending on the complexity of request. The end result of every request is a Lucinda\URL\Response object, encapsulating all response information (headers, body, status).

Running single requests

Performing a single HTTPs request is as simple as this:

This automatically sends target host embedded CAINFO certificate along with URL in order to establish a TLS connection then receives a Lucinda\URL\Response object. The class in charge of single requests is Lucinda\URL\Request, defining following public methods:

Method Arguments Returns Description
__construct ?string $url = null void Opens a cURL handle and optionally sets target URL
setURL string $url void Manually sets request URL
Throws Lucinda\URL\RequestException if url is invalid
setMethod Lucinda\URL\Request\Method $method void Sets request method as one of Lucinda\URL\Request\Method enum values otherwise assumes GET!
Throws Lucinda\URL\RequestException if request method is invalid
setParameters array $parameters = [] Lucinda\URL\Request\Parameters Sets POST request parameters directly (by key and value) or delegates to specialized class.
setRaw string $body void Sets binary request parameters, available if request method is POST / GET / DELETE!
setHeaders void Lucinda\URL\Request\Headers Sets request headers by delegating to specialized class
setSSL string $certificateAuthorityBundlePath Lucinda\URL\Request\SSL Sets custom certificate authority bundle to use in SSL requests and delegates to specialized class.
If not used, API will employ embedded cacert.pem file downloaded from official site!
setCustomOption int $curlopt,
mixed $value
void Sets a custom CURLOPT_* request option not covered by API already.
Throws Lucinda\URL\RequestException if option is already covered.
setReturnTransfer bool $returnTransfer void Sets whether or not response body should be return (default TRUE if method not used)
execute int $maxRedirectionsAllowed = 0,
int $timeout = 300000
Lucinda\URL\Response Executes request and produces a response.
Throws Lucinda\URL\RequestException if invalid request options combination was found.
Throws Lucinda\URL\ResponseException if response retrieval failed (eg: response exceeded timeout).

File Uploading

API comes with Lucinda\URL\Request extensions specifically designed for file upload. To upload a file you must use Lucinda\URL\FileUpload, which comes with following additional public methods:

Method Arguments Returns Description
__destruct void void Closes file handles created by setFile method below
setMethod Lucinda\URL\Request\Method $method void Specializes parent method to only allow POST and PUT requests
setFile string $path void Sets absolute location of file to upload, available if request method is PUT!
Throws Lucinda\URL\FileNotFoundException if file isn't found.
setRaw string $body void Sets binary body of file to upload, available if request method is POST!
setProgressHandler Lucinda\URL\Request\Progress $progressHandler void Sets handle to use in tracking upload progress.
execute int $maxRedirectionsAllowed = 0,
int $timeout = 300000
Lucinda\URL\Response Uploads file, updating response status accordingly.

Example (uploads LOCAL_FILE_PATH to REMOTE_FILE_PATH):

File Downloading

API comes with Lucinda\URL\Request extensions specifically designed for file download. To download a file you must use Lucinda\URL\FileDownload, which comes with following additional public methods:

Method Arguments Returns Description
setMethod Lucinda\URL\Request\Method $method void Specializes parent method to only allow GET requests
setFile string $path void Sets absolute location where file will be downloaded (incl. file name and extension)!
Using this method is mandatory!
setProgressHandler Lucinda\URL\Request\Progress $progressHandler void Sets handle to use in tracking download progress.
execute int $maxRedirectionsAllowed = 0,
int $timeout = 300000
Lucinda\URL\Response Downloads file, updating response status accordingly.

Example (downloads REMOTE_FILE_PATH into LOCAL_FILE_PATH):

Running multiple asynchronous requests

Performing multiple requests at once it is no less simple:

This executes two requests simultaneously using HTTP2 pipelining and receives a Response object array. The class in charge of single requests is Lucinda\URL\MultiRequest, defining following public methods:

Method Arguments Returns Description
__construct Lucinda\URL\Request\Pipelining $pipeliningOption void Initiates a multi URL connection based on one of enum values
add Request $request void Adds request to execution pool.
setCustomOption int $curlMultiOpt,
mixed $value
void Sets a custom CURLMOPT_* request option not covered by API already.
Throws Lucinda\URL\RequestException if option is already covered
setReturnTransfer bool $returnTransfer void Sets whether or not response body should be return (default TRUE if method not used)
execute bool $returnTransfer = true,
int $maxRedirectionsAllowed = 0,
int $timeout = 300000
Lucinda\URL\Response [] Validates requests in pool then executes them asynchronously in order to produce responses.
Throws Lucinda\URL\RequestException if invalid request options combination was found.
Throws Lucinda\URL\ResponseException if response retrieval failed (eg: response exceeded timeout).

Unlike native curl_multi, responses will be received in the order requests were pooled! Execution will be performed depending on pipelining option (see constructor):

Running cookie sharing synchronous requests

To make multiple requests share cookies/dns, it is as simple as:

This very poorly documented feature makes 2nd request able to see cookies in first request. The class in charge of cookie-sharing requests is Lucinda\URL\SharedRequest, defining following public methods:

Method Arguments Returns Description
__construct Lucinda\URL\Request\ShareType $shareOption void Initiates a shared URL connection based on one of enum values
add Request $request void Adds request to share pool.

Unlike the other two classes of running requests, each request must be executed manually in order to produce a response! Cookie sharing will be performed depending on share type option (see constructor):

Working with HTTP cookies

API comes with a number of classes for working with cookies, whose area is IN BETWEEN requests and responses:

They are rarely needed in everyday usage, so for more info click on their links to see documentation. To see how they can be used, please check respective unit tests!

Working with responses

The end result of every successful request (defined as one that received ANY response) is encapsulated into a Lucinda\URL\Response object that includes:

All this information can be queried via following public methods:

Method Arguments Returns Description
getDuration void int Gets total response duration in milliseconds
getStatusCode void int Gets response HTTP status code
getURL void string Gets url requested
getBody void string Gets response body
getHeaders void string[string] Gets response headers by name and value
getCustomOption int $curlinfo mixed Gets value of a custom CURLINFO_* response option not covered by API already.
Throws Lucinda\URL\ResponseException if option is already covered

Examples

HTTP GET Request

HTTP POST Request

HTTP PUT Request

HTTP DELETE Request

Error handling

Following exceptions may be thrown during request-response process by this API:

A few observations:


All versions of requester with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
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 lucinda/requester contains the following files

Loading the files please wait ....