Are there any Laravel profilers that work with JSON APIs?

I saw debugbar barryvdh, but it seems to only work when you serve the pages. Every answer from my application/json site.

Is there a hidden option that I miss in the barryvdh bar, or is there another option for profiling my L4 application?

I am not asking for ratings or opinions, just a link to any profiler that can simply send the results to an array or log file.

+8
source share
4 answers

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.

+5
source

you can use

 print_r($response); 

instead

 return response()->json($response); //comment it 

and open it in a browser (to receive requests);

It is important that you do not return anything

+3
source

In accordance with the above answers of the Laravel Debug Bar, we cannot use the rest of the APIs for profiling , the alternative that I came across is above the package:

Packagist url

Git url

Installation Procedure:

  • Step 1: Install the requirements of the Profiler package: PHP 7.1+ and Laravel 5.2+

    It is recommended that you install Profiler only for development.

composer require jkocik / laravel-profiler --dev

  • Step 2: Publish the configuration file Run the command

php artisan vendor: publish --provider = "JKocik \ Laravel \ Profiler \ ServiceProvider"

... and check the config / profiler.php file for Profiler settings.

-Step 3: install the profiler server and the profiler client. It is recommended to install the Profiler Server and Profiler Client only for development.

npm install laravel-profiler-client --save-dev

  • Step 4: Start the profiler server and the profiler client. Windows users: if you have any problems starting the Profiler Server or Profiler client, check the "Installation Settings / Issues" section below.

Run command

Craftsman php profiler: server

Toolbar View of this package:

Dashboard view

Hope this solves your problem!

+1
source

Try the Google Chrome POSTMAN extension.

-5
source

Source: https://habr.com/ru/post/1207139/


All Articles