Hi, I created a custom route for custom rest api using register_rest_route. I tried to debug some variables by using dump() or dd(), it seems working but the problem is there is no style or script. The dump() or dd() output was just a plain text. How I can enable the style and script of dump() or dd() ?
As you noted, the problem is that the response is being interpreted as plain-text rather than HTML by the browser (actually it’s probably a JSON response since it’s an API route).
You could try forcing the HTTP header to HTML like this just before doing the dd():
header('Content-Type: text/html; charset=utf-8');
I haven’t tested that myself but it should work…
Alternatively, you could just use one of the plain-text friendly functions, such as print_r(), var_dump() or var_export()