shlogg · Early preview
Paul Redmond @paulredmond

Laravel's Debugging Helpers: Dumping And Debugging HTTP Responses

Laravel's HTTP Tests have handy helpers like dump(), dumpHeaders() & dumpSession() to debug responses. Use dd() counterparts or assign response to local var for deeper debugging. Handy when chaining assertions!

Looking at Laravel’s HTTP Tests documentation carefully, you’ll notice some useful helpers built into the TestResponse class to debug HTTP responses. This class recently had some internal updates to these methods in the way of the Laravel 11's Dumpable Trait, and I thought it would be a good time to revisit these useful helpers:
$response = $this->get('/'); $response->dump();$response->dumpHeaders();$response->dumpSession();
These methods have a dd() counterpart too, which will “die and dump” response values:
$response->dd();$response->ddHeaders();$response->ddSession();
These methods are help...