So, I was disappointed with the solution I described earlier, and went ahead and created a fork of laravel-debugbar, which did exactly what I was looking for:
https://github.com/Dukeman330/laravel-debugbar
Essentially, I used the route, controller, and debugbar view, which open a full-screen version of the debug panel, making it easier to view debug files using ajax requests. If you want to try updating your composer.json as follows:
"repositories": [{ "type": "vcs", "url": "https://github.com/Dukeman330/laravel-debugbar.git" }], "require": { "barryvdh/laravel-debugbar": "dev-master" },
Then complete your ajax calls as usual, and to see the result, go to [your-site]/debugbar in the browser.
Previous answer:
This is not an ideal solution, but I worked on the same problem by setting up a small βprofilerβ page that displays my JSON output using the profiler panel. I created profiler.blade.php with the following:
<html> <body> <pre>{{json_encode($data, JSON_PRETTY_PRINT)}}</pre> </body> </html>
Then, whenever I want to profile the function I'm building, instead of return $output; I run something like:
return \View::make('profiler', ['data' => $output]);
Again, not ideal, since the caller of the rest API will not know how to handle this output, but it works pretty well if you are developing the API in a browser.