cURL wrapper

dev-master 2016-02-04 12:02 UTC

This package is not auto-updated.

Last update: 2024-12-21 20:57:34 UTC


README

Build Status

PhpWrapper\Curl

Simple cURL wrapper.

Installation

$ composer require phpwrapper/curl dev-master

Usage

<?php

use PhpWrapper\Curl;


// Init factory with default options
$curlFactory = new Curl\CurlFactory([
	[CURLOPT_SSL_VERIFYPEER, TRUE],
	[CURLOPT_SSL_VERIFYHOST, TRUE],
]);


// Create and setup cURL
$curl = $curlFactory->create('https://api.example.com/v1');
$curl->addHeader('Accept: application/json');
$curl->addParameter('myKey', 'myValue');

/** @var Curl\Response $response */
$response = $curl->get();

// or
$response = $curl->post();

// or
$response = $curl->put();

// or
$response = $curl->delete();


// Process response
var_dump($response->getStatus());
var_dump($response->getHeaders());
var_dump($response->getBody());