Doctrine ORM CLI Tool Not working

2019-07-21 05:55发布

问题:

I had doctrine version 2.3.2 , whose CLI tool was working perfectly. Now, just trying to update to ORM v2.4.4, which is having the following error just by running "./vendor/bin/doctrine" command:

PHP Catchable fatal error:  Argument 1 passed to 
Doctrine\ORM\Tools\Console\ConsoleRunner::run() must be an instance of 
Symfony\Component\Console\Helper\HelperSet, integer given, called in 
/vagrant/vendor/doctrine/orm/bin/doctrine.php on line 59 and defined in 
/vagrant/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php on line 57

Can anybody please explain what might be wrong? Thanks.

回答1:

OK, I found the solution. This requires little change in cli-config as below:

$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
    'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
    'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));
return $helperSet;

In previous versions, only including the cli-config.php file would be OK(it expected a variable named '$helperSet' ). But, in new version, it requires to return the variable and get it assigned to its internal variable.