symfony/var-dumper · error · InvalidArgumentException

Unsupported format " ".

Error message

Unsupported format "%s".

What it means

VarDumpServer's dump command supports only the formats registered in its $descriptors map (cli, html). When the --format option value has no registered descriptor, the command aborts with an InvalidArgumentException before starting the dump server.

Solutions

  1. Use a supported format: --format=cli (default) or --format=html
  2. Run `bin/console server:dump --help` to list the formats available in your installed var-dumper version
  3. Fix the typo in your script or alias config that sets the format

Example fix

// before
$php bin/console server:dump --format=json
// after
$php bin/console server:dump --format=html
Defensive patterns

Strategy: validation

Validate before calling

$formats = ['cli', 'html'];
$format = $input->getOption('format');
if (!in_array($format, $formats, true)) {
    throw new \InvalidArgumentException(sprintf('Format must be one of: %s, got "%s".', implode(', ', $formats), $format));
}

Type guard

if (!is_string($format) || !isset($descriptors[$format])) { /* reject */ }

Try / catch

try {
    $command->run($input, $output);
} catch (\InvalidArgumentException $e) {
    $io->error($e->getMessage());
    $io->note('Supported formats: cli, html');
    return Command::FAILURE;
}

Prevention

When it happens

Trigger: Running `bin/console server:dump --format=<unsupported>` where <unsupported> is not 'cli' or 'html', e.g. a typo like --format=json or a format removed in a newer var-dumper version.

Common situations: Copy-pasting a --format value from docs of another tool (e.g. --format=json), CI scripts with typos, or following outdated tutorials referencing formats that no longer exist.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of symfony/var-dumper@e9d9cf5dcd (2026-09-14). Data as JSON: /api/errors/f6cdb1e1d04ec52d. Report an issue: GitHub.

Appendix: source

Thrown at Command/ServerDumpCommand.php:82

                  <info>php %command.full_name%</info>

                You can consult dumped data in HTML format in your browser by providing the <info>--format=html</info> option
                and redirecting the output to a file:

                  <info>php %command.full_name% --format="html" > dump.html</info>

                EOF
            )
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input, $output);
        $format = $input->getOption('format');

        if (!$descriptor = $this->descriptors[$format] ?? null) {
            throw new InvalidArgumentException(\sprintf('Unsupported format "%s".', $format));
        }

        $errorIo = $io->getErrorStyle();
        $errorIo->title('Symfony Var Dumper Server');

        $this->server->start();

        $errorIo->success(\sprintf('Server listening on %s', $this->server->getHost()));
        $errorIo->comment('Quit the server with CONTROL-C.');

        $this->server->listen(static function (Data $data, array $context, int $clientId) use ($descriptor, $io) {
            $descriptor->describe($io, $data, $context, $clientId);
        });

        return 0;
    }

    public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void

View on GitHub (pinned to e9d9cf5dcd)