Vanawy
Vanawy

Reputation: 113

How to make HTTPClient request appear in Symfony profiler?

I'm using Symfony 4.4.7 and making http requests with HTTPClient (Symfony\Component\HttpClient\HttpClient) but requests doesn't shown in profiler. How to make this profiler tab work?

Upvotes: 3

Views: 1283

Answers (1)

Vanawy
Vanawy

Reputation: 113

I solved it.

You should use HttpClient using Dependency Injection then requests will appear in Profiler.

// services.yaml
App\Service\SomeService:
    arguments: 
        $httpClient: '@http_client'
...

use Symfony\Contracts\HttpClient\HttpClientInterface;
...
class SomeService
{
    protected $httpClient;
    public function __construct(HttpClientInterface $httpClient)
    {
        $this->httpClient = $httpClient;
    }
    ...
}

Upvotes: 3

Related Questions