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
Requires
- php: ^8.4
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.4
- rector/rector: *
- squizlabs/php_codesniffer: ^4.0
README
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();