200mph/curl-wrap

Lightweight CURL wrapper for PHP

Installs: 24

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/200mph/curl-wrap

3.1.0 2025-12-04 20:50 UTC

This package is auto-updated.

Last update: 2025-12-04 20:52:21 UTC


README

coverage

This is simple wrapper for PHP CURL.

<?php

use thm\curl\Curl;

// Include auto loader for testing purpose. 
// I assume you've already done it in your project.
require_once '../vendor/autoload.php';

// Initialize object
$curl = new Curl("http://api.nbp.pl/api/exchangerates/tables/A/today/?format=json");

// Change default timeout (5 seconds) - optional
$curl->setTimeout(2);
    
// GET 
$response = $curl->get();

// POST
//$response = $curl->post();
//$response = $curl->post($params, $files, $headers);

// SEND JSON
//$response = $curl->json($json);

// Binary
//$response = $curl->binary($data);

// PATCH
//$response = $curl->patch();

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

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

$status = $response->getStatus();
$body = $response->getBody();
$time = $response->getResponseTime();
$errorStr = $response->getError();
$errorCode = $response->getErrorNo();
$moreInfo = $response->getInfo();