Search code examples
symfonydebuggingvar-dump

Symfony4 vardumper server must implement DataDumperInterface error


In Symfony 4, I'm trying to use the Symfony VarDumper component and more specifically the VarDumper server.

I installed the following packages:

composer require debug --dev
composer require symfony/debug-bundle --dev
composer require symfony/var-dumper --dev

started the server:

./bin/console server:dump

and added a dump in my code

dump($entity);

but the server runs without anything getting printed in the console and whats more problematic, the code now actually fails printing this error:

Type error: Argument 5 passed to Symfony\Component\HttpKernel\DataCollector\DumpDataCollector::__construct() must implement interface Symfony\Component\VarDumper\Dumper\DataDumperInterface or be null, instance of Symfony\Component\VarDumper\Server\Connection given

What am I doing wrong here ?


Solution

  • Cerad put me on the right track. The dump server was introduced in version 4.1 but the command was available even though I was in 4.0.4. Maybe due to the packages I installed manually (var-dumper). A Symfony update to 4.1 fixed my issue.

    Thanks