Closed joelharkes closed 1 month ago
Some additional info on this from my side: I first read your article on dev.to @joelharkes while researching this exact feature. Later, I found this open issue and noticed that you are the author of both the article and this issue. 😅 The HTTP events are available at least since Laravel 8.x (https://laravel.com/docs/8.x/http-client#events)!
Next I implemented your suggested code and modified it a bit in order to show the HTTP requests in the timeline. I stripped the header & body info from my code as I didn't need them for my specific use case. I kept the logging feature since the links in the timeline are not clickable.
Further I changed the event registration to be inside the global EventServiceProvider.php
file. FYI: I didn't need to add the ClockworkMiddleware::class
into the Kernel.php
as it works just fine without it in my case.
You can find my modified implementation in this gist: https://gist.github.com/FeBe95/e6fcfd704799b0c17a02bce6ecd451ec
Apart from that I also modified Clockworks' code by adding one extra line here:
To turn it into this:
public function toArray()
{
return [
'name' => $this->name,
'description' => $this->description,
'start' => $this->start,
With this change I am able to achieve a behavior similar to how SQL queries are displayed:
I can set a short method + host/path
string in the name
field to display in the timeline bar and the full url
string in the description
field to display in the popup:
I'd love to see a default framework integration! Maybe a new "HTTP" tab could be introduced, just like the "Log" and "Database" tab. A new color + icon combination in the timeline for the requests would also be a nice addition.
I am very much looking forward to seeing this feature getting integrated into clockwork directly!
Hey, thanks for the suggestion. I will leave this for the next major release, since I want to do a more complete integration, with a new tab for the HTTP requests as suggested above.
This has been implemented a while ago and will be releasing in Clockwork 5.3 (https://github.com/itsgoingd/clockwork/pull/693).
Laravel introduced events to catch server-to-server calls made in the framework: https://laravel.com/docs/10.x/http-client#events
These can be used to catch server-to-server calls and show them in the logging or in a separate tab:
for example i did some simple HTTP request logging:
Can this be added to the default framework integration?