The CurlRequest class within the Boostack\Models\Curl namespace is designed to facilitate the management and execution of cURL requests in PHP. It provides a series of methods that allow you to configure various aspects of the request, such as the endpoint URL, GET and POST fields, custom headers, request type (GET or POST), returning the transfer as a string, and the user agent. Once the necessary parameters are configured, the class allows you to send the request and obtain the response, thereby simplifying the interaction with external APIs or other web services.


In order to use PHP's cURL functions you need to install the ยป libcurl package.

Usage Example

$request = new CurlRequest();
$request->setCustomHeader(array("Authorization: Bearer {[example api_key]}"));
    'input' => $raw_content,
    'model' => $model
$mb = $request->send();


  • CurlRequest::setEndpoint($endpoint)
    Set the endpoint where make HTTP request to the cUrl.
  • CurlRequest::setIsPost($isPost)
    The method accept boolean value (true or false) in case your request is in POST method otherwise set into FALSE.
  • CurlRequest::setReturnTransfer($returnTransfer)
    Set TRUE to return the raw output
  • CurlRequest::setGetFields($fields)
    Set the method Get with their $fields
  • CurlRequest::setPostFields($fields)
    Set the field with POST method, This parameter can be passed as an array with the field name as key and field data as value.
  • CurlRequest::setCustomHeader($data)
    The headers specified in this parameter will be used in requests both to servers and proxies. Like An array of HTTP header fields to set, in the format array('Content-type: text/plain', 'Content-length: 100').
  • CurlRequest::send()
    Execute cUrl request, and the return data can be obtained using Class MessageBag.
    The result if the cUrl request have success can be obtained by using method getData.
    In case of error you can check the existing of error using method hasError and getErrorMessage