[英]when migrate the table throws exception in laravel eloquent
Help me to resolve帮我解决
[Symfony\\Component\\Debug\\Exception\\FatalThrowableError] [Symfony\\Component\\Debug\\Exception\\FatalThrowableError]
Class 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver' not found找不到类“Doctrine\\DBAL\\Driver\\PDOMySql\\Driver”
Did you require the doctrine/dbal
package?你需要
doctrine/dbal
包吗?
If you haven't, run the following.如果还没有,请运行以下命令。
composer require doctrine/dbal
Read the section about modifying columns阅读关于修改列的部分
https://laravel.com/docs/5.6/migrations#modifying-columns https://laravel.com/docs/5.6/migrations#modifying-columns
Taken from laravel documentation取自 Laravel 文档
Before modifying a column, be sure to add the doctrine/dbal dependency to your composer.json file.在修改一个列之前,一定要在你的 composer.json 文件中添加doctrine/dbal 依赖项。 The Doctrine DBAL library is used to determine the current state of the column and create the SQL queries needed to make the specified adjustments to the column:
Doctrine DBAL 库用于确定列的当前状态并创建对列进行指定调整所需的 SQL 查询:
Run composer require doctrine/dbal
运行
composer require doctrine/dbal
Then然后
Run composer update
.运行
composer update
。
It should fix the issue.它应该解决这个问题。
composer require doctrine/dbal:^2.12.1
他们更改了 dbal 3 上的类路径,因此您将需要旧版本。
You need to generate the migration properly and then only it will work when you try to migrate the tables您需要正确生成迁移,然后只有当您尝试迁移表时它才会起作用
To create a migration you need to use the make:migration要创建迁移,您需要使用 make:migration
php artisan make:migration create_users_table
The new migration will be placed in your database/migrations directory.新迁移将放置在您的 database/migrations 目录中。 Each migration file name contains a timestamp which allows Laravel to determine the order of the migrations.
每个迁移文件名都包含一个时间戳,允许 Laravel 确定迁移的顺序。
The --table and --create options may also be used to indicate the name of the table and whether the migration will be creating a new table. --table 和 --create 选项也可用于指示表的名称以及迁移是否将创建新表。 These options pre-fill the generated migration stub file with the specified table:
这些选项使用指定的表预先填充生成的迁移存根文件:
For example,例如,
php artisan make:migration create_users_table --create=users
php artisan make:migration add_votes_to_users_table --table=users
For more information's to read about migrating tables in laravel有关在 Laravel 中迁移表的更多信息,请阅读
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.