I found a workaround for this, as you may call it that, or maybe rather just a way to enable the commands.
By adding a Command to one of your own bundles (or a dedicated one, is up to you), you can simply subclass the Doctrine command. E.g. to enable the dbal:import command use the following:
namespace Acme\Bundle\AcmeBundle\Command\Doctrine;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
class ImportCommand extends \Doctrine\DBAL\Tools\Console\Command\ImportCommand {
protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getApplication()->getKernel()->getContainer();
$doctrine = $container->get('doctrine');
$em = $doctrine->getEntityManager();
$db = $em->getConnection();
$helperSet = $this->getHelperSet();
$helperSet->set( new ConnectionHelper( $db ), 'db' );
$helperSet->set( new EntityManagerHelper( $em ), 'em' );
parent::execute( $input, $output );
}
}
As you can see, we simply subclass the original command. Since the database configuration is managed by Symfony we need to get the entity manager through the container. Once we update the HelperSet we pass execution back to the parent class.
bin/doctrine.bin/doctrineis that it doesn't understand the--envparameter. I want these commands to be available fromapp/console.