laravel php artisan migrate:找不到类架构
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43806387/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
php artisan migrate: Class Schema not found
提问by FranMoronR
When doing a migration, in the Windows console I execute the command:
进行迁移时,我在 Windows 控制台中执行以下命令:
php artisan migrate
When I run the command, it shows me the following error:
当我运行命令时,它显示以下错误:
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Market\Providers\Schema' not found
I would be very grateful if anyone can help me.
如果有人能帮助我,我将不胜感激。
回答by Sabyasachi Ghosh
add following line on the top of that page (AppServiceProvider.php under providers directory)
在该页面的顶部添加以下行(Providers 目录下的 AppServiceProvider.php)
use Illuminate\Support\Facades\Schema;
回答by Yevgeniy Afanasyev
It looks like you have fixed another problems with the message "Laravel 5.4: Specified key was too long error" using this articlewhere you were recommended to add following code
它看起来像你有固定与消息的另一个问题“Laravel 5.4:指定的键过长错误”使用这篇文章,你是建议添加以下代码
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
to the file named
到名为的文件
AppServiceProvider.php
应用服务提供者.php
and you actually only changed the boot
method and forget to update the use
section. Am I right?
而您实际上只是更改了boot
方法而忘记更新该use
部分。我对吗?
The Article says:
文章说:
Laravel 5.4 made a change to the default database character set, and it's now utf8mb4 which includes support for storing emojis. This only affects new applications and as long as you are running MySQL v5.7.7 and higher you do not need to do anything.
For those running MariaDB or older versions of MySQL you may hit this error when trying to run migrations:
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email)) [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
Laravel 5.4 对默认数据库字符集进行了更改,现在是 utf8mb4,其中包括对存储表情符号的支持。这只会影响新应用程序,只要您运行 MySQL v5.7.7 及更高版本,您就不需要做任何事情。
对于那些运行 MariaDB 或旧版本 MySQL 的用户,在尝试运行迁移时可能会遇到此错误:
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email)) [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
回答by jedrzej.kurylo
It seems your migration code is in a namespace and that's where PHP is looking for Schemaclass. Add the following at the top of your file:
看来您的迁移代码在一个命名空间中,这就是 PHP 寻找Schema类的地方。在文件顶部添加以下内容:
use Schema;
or refer to the Schemaclass using fully qualified namespace:
或使用完全限定的命名空间引用Schema类:
\Schema::table(...);