工匠迁移错误"类'Doctrine \\ DBAL \\ Driver \\ PDOMySql \\ Driver'not found",

Nan*_*mic 17 php symfony laravel laravel-5

尝试运行迁移时,我收到Artisan迁移错误

错误:Class 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver' not found

我在这里阅读了这些问题,并看到了要添加的注释:

doctrine/dbal": "~2.3 在composer.json的requires部分

Github Bug报告

但是,我不明白发生了什么.几天前我创建了一张表,没有任何问题.

在composer.son中添加该依赖项后,我无法弄清楚要做什么.

我不想意外更新任何其他包.

Avi*_*aut 61

在我的情况下,composer install 和 composer install 都不起作用,给出了相同的错误“找不到类‘Doctrine\DBAL\Driver\PDOMySql\Driver’”,

下面给出了我为使其可行所做的更改

composer.json 文件已更改

 "doctrine/dbal": "^3.0",
Run Code Online (Sandbox Code Playgroud)

这改变了

"doctrine/dbal": "^2.0",
Run Code Online (Sandbox Code Playgroud)

然后运行命令

composer update 
Run Code Online (Sandbox Code Playgroud)


Mah*_*bub 59

doctrine/dbal 依赖需要添加到你的 composer.json

composer require doctrine/dbal
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请查看laravel #Modifying Columns

  • 这是正确的答案。请授予答辩者的同意 (2认同)

Abd*_*rad 21

您必须降级当前版本,这对我有用:

composer require doctrine/dbal:2.*
Run Code Online (Sandbox Code Playgroud)


DEV*_*nça 14

# For Laravel 6x/7x:    
composer require doctrine/dbal:"^2.0"
    
# For Laravel >= 8x:    
composer require doctrine/dbal
Run Code Online (Sandbox Code Playgroud)


小智 12

如果您使用的是学说 3,请降级到"doctrine/dbal": "^2.10.3"(我不知道 laravel 是否更新了学说 3 的迁移工具。如果是,您应该更新 Laravel 工具)。他们重命名了类并且 Doctrine\\DBAL\\Driver\\PDOMySql\\Driver不存在


小智 11

Laravel

谁在拥有学说/dbal 时遇到过这个问题”:需要“3.0”aleady:将其降级回

"doctrine/dbal": "^2.10".
Run Code Online (Sandbox Code Playgroud)

如果您仍然面临问题,例如获取

Laravel\Passport\Bridge\AccessToken::__toString() 不能抛出异常

您应该需要 lcobucci/jwt 的上一个版本。它刚刚自动更新到 3.4,这对我造成了这些问题。我花了大约 3-4 个小时来追踪这一切。希望它也能帮助别人。

composer require lcobucci/jwt 3.3.3
Run Code Online (Sandbox Code Playgroud)


小智 9

如前所述,使用composer require doctrine/dbal,如果由于某种原因不起作用,请使用较低版本composer require doctrine/dbal:^2.12.1,然后运行composer dumpautoload -o.


Mah*_*tap 6

跑步

composer update
Run Code Online (Sandbox Code Playgroud)

它将安装您缺少的软件包,例如 PDOMySql。

或者

删除vendor文件夹并运行

composer install
Run Code Online (Sandbox Code Playgroud)