Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

man-u-l's avatar

Http::withToken get total time of request

I read over the docs and I cannot find a way to get the total time it takes for a request to execute, Im logging this to get an idea of how long it takes for an API to respond, any help will be greatly appreciated.

When I try

$response->transferStats->transferTime

I get "Cannot access private property GuzzleHttp\TransferStats::$transferTime"

And the above gives me the info I need.

I have also tried the withOptions and added array:

'on_stats' => function (TransferStats $stats) { return $stats->getTransferTime(); }

But I get error: Second array member is not a valid method

0 likes
2 replies
s4muel's avatar
s4muel
Best Answer
Level 50

getTransferTime() is public method (getter), try that.

$response->transferStats->getTransferTime()

1 like

Please or to participate in this conversation.