场景:
使用Laravel-admin创建Controller的时候报错:
Symfony\Component\Debug\Exception\FatalThrowableError : Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found
at D:****\LaravelAdmin\vendor\laravel\framework\src\Illuminate\Database\MySqlConnection.php:65
61| * @return \Doctrine\DBAL\Driver\PDOMySql\Driver
62| */
63| protected function getDoctrineDriver()
64| {
> 65| return new DoctrineDriver;
66| }
67|
68| /**
69| * Bind values to their parameters in the given statement.
Exception trace:
1 Illuminate\Database\MySqlConnection::getDoctrineDriver()
D:****\LaravelAdmin\vendor\laravel\framework\src\Illuminate\Database\Connection.php:887
2 Illuminate\Database\Connection::getDoctrineSchemaManager("users")
D:****\LaravelAdmin\vendor\encore\laravel-admin\src\Console\ResourceGenerator.php:224
Please use the argument -v to see more details.
在网上找寻了一番,说是因为没有装一个doctrine/dbal
的驱动,于是执行如下命令进行安装:
composer require doctrine/dbal
执行成功之后还是不行,还是报一样的错,于是通过一番资料的查找:
1. 确认了是`doctrine/dbal`正常安装;
2. 确认`pdo_mysql `扩展开启;(php -m即可查看当前环境的所有扩展)
这两点都确认了没问题,在stackoverflow上偶然间看到可能是doctrine/dbal
版本的问题,于是抱着试一试的态度尝试了一下:
composer require doctrine/dbal:2.*
之后再创建控制器:
成功解决这个问题!