curl_setopt_array(): cannot represent a stream of type Outpu

发布时间:2023-05-18作者:冰貂主人点击:162

在guzzle(版本6.3)设置了option中debug为true的时候,linux下没有问题,windows下报如下错误:
curl_setopt_array(): cannot represent a stream of type Output as a STDIO FILE*
// 发送请求
        $resp = $instance->chain('v3/certificates')->get(
            // 调试模式,https://docs.guzzlephp.org/en/stable/request-options.html#debug
            ['debug' => false]或者['debug'=>fopen('php://stdout','w')]

        );
文件路径..\vendor\guzzlehttp\guzzle\src\Utils.php 搜“debugResource”简单改代码就好
更改后代码   
public static function debugResource($value = null)
    {
        if (\is_resource($value)) {
            return $value;
        }
        if (\defined('STDOUT')) {
            return \STDOUT;
        }
		$out='php://output';
		if(strtoupper(substr(PHP_OS,0,3))==='WIN'){ //判断系统改输出模式
			$out='php://stdout';
		}
        return \GuzzleHttp\Psr7\Utils::tryFopen($out, 'w');
    }
标签: