Certainly! Here’s an explanation and solution you could post as an answer:
When you fire HTTP client calls via routes/controllers in your Laravel app, Telescope tracks them because the middleware stack is loaded and Telescope’s service provider is bootstrapped as part of the normal web (or API) request lifecycle.
However, when you run code via Tinker, Tinkerwell, or even jobs/commands, you are operating in a different context:
- The HTTP middleware for web/requests is not running.
- Telescope's request tracking is specifically enabled during web (or API) requests or when the App is booted normally in the container, not via Artisan (e.g., Tinker or Commands).
That’s why you don’t see HTTP client calls tracked in Telescope when called from Tinker.
This is by design to avoid clutter and overhead during CLI or testing usages.
Solution / Workarounds
1. Make Calls Through a Route
If you need to debug/track certain HTTP calls, trigger them through a route/controller. Telescope will log them automatically.
Route::get('/test-http', function() {
return Http::get('http://example.com/users/1')->body();
});
2. Programmatically Record Telescope Entries
If you must log HTTP client calls from Artisan commands or Tinker, you can manually create Telescope entries. Example:
use Laravel\Telescope\Telescope;
use Laravel\Telescope\EntryType;
Telescope::recordRequest([
// Note: This is a hacky approach; not all data fields may apply
'type' => EntryType::REQUEST,
'content' => [
'method' => 'GET',
'uri' => 'http://example.com/users/1',
'headers' => [],
'response_status' => $response->status(),
'response_headers' => $response->headers(),
// ...other info
]
]);
This requires you to structure the data as Telescope expects. It is not ideal or recommended unless necessary.
3. Write a Custom Telescope Watcher (Advanced)
You could write a custom Telescope Watcher to track HTTP client calls from CLI/Tinker.
See Custom Watchers in the Telescope docs for how to create and register your own Watcher.
4. Use Laravel Debugbar
For local CLI/debugging, Laravel Debugbar is another tool that may give insights, though it, too, usually works in the request context.
Summary
Telescope by default does not track HTTP Client calls made from Tinker, jobs, or cli/command contexts.
It tracks per-request data in HTTP contexts, to avoid unexpected data or performance problems when running background or manual scripts.
If you want tracking, trigger the code via a route or implement your own watcher or logging for debugging purposes.
Hope that clarifies things for you!