I recently ran into an issue where the Laravel dd()
helper function did not display anything to my browser when calling it in any place and simply responded with a HTTP 500 and literally 0 bytes of body.
I was digging around and found out that spatie/ignition - the pretty error pages you'll see on unhandled Exceptions - will replace the Synfony VarDumper Handler with a kind of middleware that collects all dumps (and displays them when another Exception is thrown? idk).
Well, how to get it working again?
Define a new environment variable VAR_DUMPER_FORMAT
inside your project.
VAR_DUMPER_FORMAT=any
The value any
isn't actually defined an can be replaced by any gibberish text. There are some special cases:
html
: Always display the dump as HTML - also in CLI applicationscli
: Always display the dump in CLI formatserver
: Dumps via a remote connection, onlyserver
actually just dumps to HTML or CLI based on the runtimetcp://...
: Dumps to a remote server via TCP
Details
Inside the VarDumper class, a setHandler
method used by Laravel-Ignition will check if the previously mentioned environment variable is set and prevents overriding the existing handler.
public static function setHandler(?callable $callable): ?callable
{
$prevHandler = self::$handler;
// Prevent replacing the handler with expected format as soon as the env var was set:
if (isset($_SERVER['VAR_DUMPER_FORMAT'])) {
return $prevHandler;
}
self::$handler = $callable;
return $prevHandler;
}
Read more...
How to style <progress> Element with Tailwind
Styling the HTML progress element isn't as straight forward as you think. We'll take a look and craft pretty progresses with Tailwind CSS.
How to use a Custom Domain for Local Development on macOS
How to setup a custom domain for your Lando projects using dnsmasq on macOS, step-by-step guide
Comments