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

patake's avatar

Telescope http client not logging api requests on command class

I created a new Command class that makes a Http call to an external API.

Everything works fine but Telescope is not logging this API call.

I made a simple test directly on web.php with:

Route::get('/guzzle-test', function () {
    Http::post('https://jsonplaceholder.typicode.com/posts', ['title' => 'test']);
});

and Telescope logged successfully.

So, the question is:

Telescope doesn't log API calls inside a command class? If it's true, It's possible to log this calls? It's a configuration issue?

Thanks in advance.

0 likes
1 reply
LaryAI's avatar
Level 58

Telescope does not log API calls inside a command class by default. However, it is possible to manually log these calls using Telescope's telescope() helper function. Here's an example of how to do this:

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
use Laravel\Telescope\Telescope;

class MyCommand extends Command
{
    protected $signature = 'my:command';

    public function handle()
    {
        // Make the API call
        $response = Http::post('https://jsonplaceholder.typicode.com/posts', ['title' => 'test']);

        // Log the API call using Telescope
        Telescope::recordRequest($response->url(), $response->method(), $response->status(), $response->json(), [
            'command' => 'my:command',
        ]);
    }
}

In this example, we're using Telescope's recordRequest() method to manually log the API call. We're passing in the URL, HTTP method, status code, response body, and some additional metadata (in this case, the name of the command that made the API call).

Note that you'll need to make sure that Telescope is properly configured and enabled in your application for this to work.

Please or to participate in this conversation.