var-dump-server
Debug PHP code by providing variable dumps
TLDR
Start the server
Dump the data in an HTML file
Make the server listen on a specific address and port
SYNOPSIS
var-dump-server [options]
PARAMETERS
--host[=HOST]
The host and port to listen on (e.g., 127.0.0.1:9912). Defaults to 127.0.0.1:9912.
--format[=FORMAT]
The output format for the dumped data. Available formats include txt, html, cli (default), ide, and dump-id.
--ide-link-format[=IDE-LINK-FORMAT]
Specifies a format string to generate clickable links to the source file in an IDE (e.g., phpstorm://open?file=%%f&line=%%l or vscode://file/%%f:%%l).
-v, --verbose
Increases the verbosity of messages: 1 for normal output, 2 for more verbose output, and 3 for debug output.
-q, --quiet
Suppresses all command output, showing only critical errors or interactive prompts.
-V, --version
Displays the application's version information.
--ansi
Forces ANSI escape codes for colored output, even if not detected automatically.
--no-ansi
Disables ANSI escape codes, preventing colored output.
-n, --no-interaction
Does not ask any interactive questions during command execution.
-h, --help
Displays help information for the given command. If no command is specified, displays help for the list command.
DESCRIPTION
The var-dump-server command is a dedicated server that receives and displays debugging output generated by PHP applications, primarily through the symfony/var-dumper component. It acts as a central sink for var_dump() calls, allowing developers to view complex data structures without interfering with the application's HTTP response or log files. This tool is invaluable for debugging during development, providing a clean, real-time stream of debugging information in a console or other specified formats, thus significantly improving the debugging workflow for PHP developers.
CAVEATS
The var-dump-server is primarily a development and debugging tool and is not intended for use in production environments. It requires the symfony/var-dumper component to be installed and configured in the PHP application to send data to the server. Running it continuously consumes system resources. Ensure the specified host and port are free and accessible.
HOW IT WORKS
The var-dump-server operates on a client-server model.
When started, it listens on a specified host and port for incoming connections. In the PHP application, the symfony/var-dumper component is configured (typically via environment variables or a configuration file) to send its dump output to this server instead of directly to stdout or the browser. This allows developers to inspect complex data structures in a separate terminal window, keeping the browser output clean and preventing potential issues with large dumps breaking HTTP responses or exceeding memory limits.
The server receives the serialized dump data, unserializes it, and then displays it in the chosen format (e.g., CLI, HTML, or IDE-friendly format).
HISTORY
The var-dump-server is an integral part of the symfony/var-dumper component, which was introduced to the Symfony framework to provide a more powerful and user-friendly alternative to PHP's built-in var_dump() function. Its development aimed at improving the developer experience by offering richer output formats and the crucial ability to dump data to a dedicated server, thereby decoupling debugging output from the traditional web response cycle. It has evolved consistently with the Symfony framework's releases, becoming a standard debugging utility for many PHP projects.