I want to use the HttpClientInterface from symfony, so i added it in __construct like this:
private HttpClientInterface $client;
/**
* @param HttpClientInterface $client
*/
public function __construct(
HttpClientInterface $client
) {
$this->client = $client;
}
And just a simple request in my function:
$response = $this->client->request(
'GET',
'https://mywebsite.com/api/call/myId'
);
So when i try to run it i get this error:
Cannot autowire service "App\MyService": argument "$client" of method "__construct()" references interface "Symfony\Contracts\HttpClient\HttpClientInterface" but no such service exists. You should maybe alias this interface to the existing "monolog.http_client" service.
I tried to add it to services as it said above but i also got an error:
Like this (monolog.http_client: or http_client:)
Error: here is no extension able to load the configuration for "monolog.http_client"
So i really have no idea how to solve this problem!!
I had to add http_client: under framework: in services.yml