php安装psr7应用,如何修复“预期类型”psr\http\message\requestinterface。在php laravel中发现“guzzlehttp\psr7\request”错误?…

  • Post author:
  • Post category:php


我想发邮件,所以我试着用

guzzlehttp/guzzle

为此,这给我带来了一个错误。

我试着改变类型

Psr7\Request

\Psr\Http\Message\RequestInterface

但它也不起作用,给我带来了另一个错误

‘无法实例化接口psr\http\message\requestinterface’。

所以我不知道该怎么办?啊!

public function requestAsync($method, $uri = ”, array $options = [])

{

$options = $this->prepareDefaults($options);

// Remove request modifying parameter because it can be done up-front.

$headers = isset($options[‘headers’]) ? $options[‘headers’] : [];

$body = isset($options[‘body’]) ? $options[‘body’] : null;

$version = isset($options[‘version’]) ? $options[‘version’] : ‘1.1’;

// Merge the URI into the base URI.

$uri = $this->buildUri($uri, $options);

if (is_array($body)) {

$this->invalidBody();

}

$request = new Psr7\Request($method, $uri, $headers, $body, $version);

// Remove the option so that they are not doubly-applied.

unset($options[‘headers’], $options[‘body’], $options[‘version’]);

return $this->transfer($request, $options);

}

它带来了这个错误

(需要类型“psr\http\message\requestinterface”。找到

‘guzzlehttp\psr7\request’)。