flexyproject / curl
A PHP7 object-oriented wrapper of the cURL extension
Installs: 5 272
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 2
Open Issues: 0
Requires
- php: >=7
- ext-curl: *
README
This is a PHP7 object-oriented wrapper of the cURL extension.
Installation
composer require flexyproject/curl
Usage
require 'vendor/autoload.php'; use \FlexyProject\Curl\Client; // Create Client object $curl = new Client(); // Set Url $curl->setUrl('https://api.github.com/user'); // Set options (here authentication options) $curl->setOption([ CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => sprintf('%s:%s', 'user', 'pass') ]); // Success callback $curl->success(function (Client $instance) { $instance->getHeaders(); // Get headers info $instance->getResponse(); // Get response body }); // Error callback $curl->error(function (Client $instance) { $instance->getHeaders(); // Get headers info $instance->getResponse(); // Get response body }); // Perform request $curl->perform();