This package is abandoned and no longer maintained. The author suggests using the php-http/httplug package instead.

A PHP7 object-oriented wrapper of the cURL extension

1.1.3 2016-08-20 23:53 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:56:27 UTC


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();