请帮我找出应该如何将buzz http bundle注入到我的服务中,以从我的服务发送请求。
我的services.yml文件:
我的services.yml文件:
parameters:
app_bundle.webUrl: https://url.com/
app_bundle.Url: https://test.com
app_bundle.token: rerwe9888rewrjjewrwj
services:
app_bundle.send_message:
class: AppBundle\Utils\SendMessage
arguments: ["%app_bundle.webUrl%, %app_bundle.Url%, %app_bundle.token%, @buzz"]
My AppBundle\Utils\SendMessage
<?php
namespace AppBundle\Utils;
class SendMessage
{
/**
* SendMessage constructor.
*
* @param $webUrl
* @param $Url
* @param $token
* @param Browser $buzz
*/
public function __construct($webUrl, $Url, $token, Browser $buzz)
{
$this->webUrl = $webUrl;
$this->Url = $Url;
$this->token = $token;
$this->buzz = $buzz;
}
/**
* @param $action
* @param null $data
* @return mixed
*/
private function sendRequest($action, $data = NULL)
{
$headers = array(
'Content-Type' => 'application/json',
);
$response = $this->buzz->post($this->Url . $this->token . '/' . $action, $headers, json_encode($data));
return $response;
}
}
但是这导致了错误:
request.CRITICAL: 未捕获的PHP异常 Symfony\Component\Debug\Exception\FatalThrowableError: "类型错误: AppBundle\Utils\SendMessage::__construct()的第4个参数必须是Buzz\Browser的实例,但没有给出,调用位置在/app/var/cache/prod/appProdProjectContainer.php的第270行", 在/app/src/AppBundle/Utils/SendMessage.php的第21行 {"exception":"[object]