首页 > 解决方案 > Symfony 5:驱动程序发生异常:找不到驱动程序

问题描述

我在 symfony 上创建了一个命令,我需要使用“EntityManagerInterface”,才能应用到存储库。

应用程序的所有其余部分工作正常,与数据库的连接以及 php 的 mysql 扩展都正常。

<?php
namespace App\Command;

use App\Entity\Block;
use App\Service\TatumService;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class CheckTransactionsCommand extends Command
{
    // the name of the command (the part after "bin/console")
    protected static $defaultName = 'app:check-transac';

    private $tatum;

    private $em;

    private $buyToken;

    public function __construct(TatumService $tatumService, EntityManagerInterface $em)
    {
        $this->em = $em;
        $this->tatum = $tatumService;
        parent::__construct();
    }

    protected function configure(): void
    {
        // ...
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $output->writeln('-------Start ETH-------');
        $ethTransactions = $this->tatum->getTransactionsEth();

        $blockRepository = $this->em->getRepository(Block::class)->findAll();
    }
}

我有以下错误:

$ php bin/console app:check-trans
-------Start ETH-------

In AbstractMySQLDriver.php line 128:
                                                          
  An exception occurred in driver: could not find driver  
                                                          

In Exception.php line 18:
                         
  could not find driver  
                         

In PDOConnection.php line 40:
                         
  could not find driver  

bdd 配置没问题,因为应用程序的其余部分工作正常。

当我不使用 ->findall() 时。该脚本工作正常。

谢谢你的帮助。

标签: phpsymfonysymfony5

解决方案


推荐阅读