New version of CurlWrapper (v1.1.0) - OOP wrapper for cURL

My scripts 15:51 / 05.07.2021 17

You can read more about CurlWrapper, a small and simple OOP wrapper for PHP cURL with no overhead, in this publication.

The new version (v1.1.0) adds functionality for setting basic configuration parameters:

  • User-Agent
  • Timeout
  • Referer

Information

Example of using version v1.1.0

File: examples/simple_request.php
use Icemont\cURL\CurlWrapper;

$curl = new CurlWrapper();

/*
 * Changing the configuration parameters
 */
$curl->setTimeout(5);
$curl->setUserAgent('Mozilla/5.0 (compatible; CurlWrapper/1.1)');
$curl->setReferer('https://example.com/');

/*
 * Adding the header and parameters
 */
$curl->addHeader('API-Key: TEST_KEY');
$curl->addParam('test', 'value');
$curl->addParam('param2', 'value2');

/**
 * Executing the query
 */
var_dump($curl->request('https://httpbin.org/post'));

echo 'Request response code: ' . $curl->httpcode . PHP_EOL;
echo 'Request error string: ' . $curl->lasterror . PHP_EOL;