Today my cURL is starting to show me this error Could not resolve: {local-domain.test} (domain name not found)
All working fine if I'm trying to get some info from an external link, but local sites aren't working properly.
So, here is my code
public function send($type, $url, $data)
{
$type = strtolower($type);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if ($type == 'post') {
$urlWithData = http_build_query($data);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, $urlWithData);
}
$result = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$out = new \stdClass();
$out->status = $status;
$out->body = json_decode($result, true);
return $out;
}
All start to work if I will add that host into my /etc/hosts/ file but I have a huge list of the domain and before updating PHP all worked fine on my side. I'm using dnsmasq as a dynamic host resolving tool.
Some debug info:
curl -v local-domain.test
from a terminalCURLOPT_DNS_USE_GLOBAL_CACHE
option.Maybe I forgot to add something to the php.ini
of each PHP? Also, all worked fine before I've made updating process of them all.
This answer on this thread worked for me.
Running:
brew uninstall curl-openssl --ignore-dependencies
(removes the last version of curl-openssl
, ensuring parity between curl versions used by your system and PHP)
... then followed by a valet restart
... allowed local curl
to resolve Valet hostnames properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With