rompetomp / inertia-bundle

Inertia.js server-side adapter for Symfony
MIT License
152 stars 39 forks source link

Auto-update the Debug Toolbar on Inertia page load #14

Closed jaydiablo closed 3 years ago

jaydiablo commented 4 years ago

Is it possible for this bundle to send the Symfony-Debug-Toolbar-Replace header (as described here: https://symfony.com/blog/new-in-symfony-4-1-self-updating-debug-toolbar) to replace the Symfony debug toolbar's "current page" with the request that responded to the Inertia.js page request (i.e. when clicking on an inertia powered link)?

I didn't see mention of this in the docs at all (and nothing came up when searching here on github).

Currently just the XHR section of the toolbar updates when navigating via inertia links.

Thanks for your work on this bundle!

jaydiablo commented 4 years ago

I was able to make the toolbar update to the response that has the X-Inertia header set to true by adding this:

'Symfony-Debug-Toolbar-Replace' => 1,

here: https://github.com/rompetomp/inertia-bundle/blob/master/Service/Inertia.php#L133

But it is recommended to only do this in the dev environment using kernel event listeners: https://symfony.com/doc/current/profiler.html#updating-the-web-debug-toolbar-after-ajax-requests

rompetomp commented 3 years ago

Hi jaydiablo

Sorry for the late reply. Please make a Pull Request if you want this added. I'm not using the package myself anymore, so I'm not actively developing on it. :-)