卷曲:显示“卷曲”;Can';t解析域名“;PHP中所有本地主机站点的错误
今天我的cURL开始告诉我这个错误卷曲:显示“卷曲”;Can';t解析域名“;PHP中所有本地主机站点的错误,php,curl,dnsmasq,Php,Curl,Dnsmasq,今天我的cURL开始告诉我这个错误无法解决:{local domain.test}(未找到域名) 如果我试图从外部链接获取一些信息,但本地站点无法正常工作,那么一切都正常 这是我的代码 public function send($type, $url, $data) { $type = strtolower($type); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url);
无法解决:{local domain.test}(未找到域名)
如果我试图从外部链接获取一些信息,但本地站点无法正常工作,那么一切都正常
这是我的代码
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;
}
如果我将该主机添加到/etc/hosts/文件中,所有这些都可以开始工作,但在更新PHP之前,我有一个巨大的域列表
对我来说一切都很好。我使用dnsmasq作为动态主机解析工具
- 操作系统:MacOs High Siera
- Apache:2.4.37
- PHP:多个PHP版本,从5.6-7.3
- 从终端Ping到该域工作正常(显示localhost)
- 即使我从终端运行
curl-v local domain.test,一切都正常
- 我尝试使用
选项CURLOPT\u DNS\u use\u GLOBAL\u CACHE
- 已从终端清除我的计算机的所有DNS缓存
php.ini
中添加一些东西?而且,在我对它们进行更新之前,它们都工作得很好 on为我工作
运行:
brew uninstall curl-openssl --ignore-dependencies
(删除最新版本的curl openssl
,确保系统和PHP使用的curl版本之间的奇偶性)
。。。然后是一次代客泊车重新启动
。。。允许本地
curl
正确解析代客泊车主机名。遇到同样的问题。我在PHP7.3.0上没有这个问题。此问题在7.3.1和7.3.2中已经存在。我使用的是Laravel Valet,通过php使用curl进行dns解析时,没有使用dnsmasq给出的规则。编辑/etc/hosts工作正常-不确定dnsmasq被忽略的原因可以确认我还必须将我的本地站点添加到主机文件(例如:127.0.0.1)。PHP7.2使用Valet+。