How to display the symfony profiler for API request made in the browser?

前端 未结 5 1038
-上瘾入骨i
-上瘾入骨i 2021-02-02 08:15

I\'m developing a REST api with Symfony2 + FOSRest bundle.

I would like to know if there is any way for a call to the api in dev mode (app_dev.php) from the

5条回答
  •  无人共我
    2021-02-02 08:31

    With the FOSRestBundle, I use a special template to display the data in an html page, therefore with the debug toolbar.

    In my controller with annotations (you also use corresponding methods):

    @View(template="AppBundle:Api:data.html.twig", templateVar="data")
    

    And in the template, choosing whatever format you fancy:

    
        
    {{ data | serialize('json') }}

    It is obviously a quick&dirty solution, but does the job. It also limits the ability to display actual html pages on those routes.

提交回复
热议问题