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

Sturm's avatar
Level 5

Debugbar for an API?

Our company uses Laravel (8.0) only for an API. We currently have some legacy PHP/JavaScript code on the front-end which calls the API. (We're working on a new React.js front-end.)

I've been tasked with determining why certain Eloquent/database calls take a very long time to execute. As a part of this, I figured adding DebugBar would be helpful, as it would show me how many queries are being run on a page, how much memory is being used, how many models are loaded, etc.

Unfortunately, because we use Laravel only for an API, installing DebugBar didn't do anything. I guess it just had no way to display that information on our legacy front-end.

I also tried installing Laravel Telescope but got effectively the same result. Going to https://itms.ourdomain.io/telescope (real domain obscured) only resulted in an nginx 404 page. (That domain name is how we access our local dev environment since we use a combination of custom Docker containers--php8_fpm, postgres, etc.)

Is there another tool I can use? Or is there some way I can make one of these two tools work in our environment?

0 likes
14 replies
Sturm's avatar
Level 5

@Snapey Does Ray have the ability to count the number of Models loaded or how much memory is used, the same way Debugbar does? I've only seen that it can show queries, events, HTTP requests, etc.

Snapey's avatar

@Sturm They both have their place. Ray does not show aggregate data like debugbar does at the end of the request cycle. You can though show all queries and the measure method will show the memory usage

1 like
Sturm's avatar
Level 5

@Sinnbeck Unfortunately, Clockwork does not work in our environment. After installing it via its instructions (composer require itsgoingd/clockwork), I cannot sign in to our app anymore. 🤷🏻‍♂️

Sinnbeck's avatar

@Sturm Do you get an error? I have used it a lot in the past without problems. I dont use it any more, as I work on SPA's now which work with debugbar :)

Sturm's avatar
Level 5

@Sinnbeck No error as such, just a redirect (302) back to the same login screen, but with our internal "System error caused login to fail." message pasted on it. I'd have to dive into our auth code, I guess, to find why the login is failing and redirecting to the error-messaged login page. However, I don't have time for that.

It seems like Ray might work for my needs right now. We'll see. If not, I might come back to Clockwork and see if I can figure out why it's preventing sign-ins. Thank you for your help.

Sinnbeck's avatar

@Sturm one thing you can try. Install debugbar and visit the page where the ajax request is made and trigger it. Now in debugbar, click the small folder icon in the top right corner. If you see the ajax request, select it and debugbar should show it instead of the page data

Sturm's avatar
Level 5

@Sinnbeck I cannot use Debugbar. The API (which uses Laravel) is in a completely different repository (and, thus, directory) from the front-end code. And the front-end code isn't Laravel-based; it has no framework and is just plain HTML/PHP/JavaScript. I don't think there's any way to make the Debugbar appear on any page because Laravel and the front-end code are decoupled like this.

Sinnbeck's avatar

@Sturm ah sorry to hear that. Hope you don't spend too much time fighting that set up :) but good that you found a solution

emaia's avatar

Is not the best way but you can try to change the api response to a simple Blade View instead a json response while debugging and you will see the debug bar.

When hit https://itms.ourdomain.io/ do you hit the Laravel app or a independent frontend/app? Seems not to be Laravel because you got 404 when trying access Telescope. Instead you need to go to https://yourLaravelAppRoot/telescope

Hope helps

Sturm's avatar
Level 5

@emaia Navigating to that URL goes to a separate front-end app in a different repository and, thus, a different directory.

So, are you saying I should just add a new /telescope route to /routes/api.php or /routes/web.php? And what should that route point to? AFAIK, Telescope doesn't create a view in the typical /resources/views directory. Perhaps it should point to the view under the /vendor/laravel/telescope directory?

Sturm's avatar
Level 5

@emaia Although it took me a bit to parse what you were saying, I got some help from a coworker today. They pointed out that all of our API calls go to https://itms-api.domain.io, so slapping the /telescope on the end finally takes me to Telescope.

Thank you so much!

1 like

Please or to participate in this conversation.