A lightweight CURL wrapper for php
composer require flashytime/curl
$curl = new \Flashytime\Curl\Curl();
or
$curl = \Flashytime\Curl\Curl::init();
$curl->url($url)->get();
or
//$params is a query parameter array, like ['id' => 1, 'uid' => 2]
$curl->url($url, $params)->get();
//$data is a multi array
$curl->url($url)->set($data)->post();
$curl->url($url)->set($data)->put();
$curl->url($url)->set($data)->patch();
$curl->url($url)->delete();
$curl->url($url)->download($file);
//$option is the CURLOPT_XXX option
$curl->setOption($option, $value)
->url($url)
->set($data)
->post();
or
$curl->setOptions([$option1 => $value1, $option2 => $value2])
->url($url)
->set($data)
->post();
if ($curl->error()) {
var_dump($curl->message());
}
//the response data
$response = $curl->response();
$curl->close();
MIT