Laravel 迁移:“未找到"类
我正在将 Laravel 准系统项目部署到 Microsoft Azure,但是每当我尝试执行 php artisan migrate
时,我都会收到错误消息:
I am deploying a Laravel barebone project to Microsoft Azure, but whenever I try to execute php artisan migrate
I get the error:
[2015-06-13 14:34:05] production.ERROR: 异常 'SymfonyComponentDebugExceptionFatalErrorException' 在 D:homesitevendor 中出现消息 'Class '' not found'laravelframeworksrcIlluminateDatabaseMigrationsMigrator.php:328
[2015-06-13 14:34:05] production.ERROR: exception 'SymfonyComponentDebugExceptionFatalErrorException' with message 'Class '' not found' in D:homesitevendorlaravelframeworksrcIlluminateDatabaseMigrationsMigrator.php:328
堆栈跟踪:
#0 {main}
可能是什么问题?非常感谢
What could be the problem? Thank you very much
迁移类
<?php
use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;
class CreateUsersTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function(Blueprint $table)
{
$table->bigIncrements('id');
$table->string('name', 50);
$table->string('surname', 50);
$table->bigInteger('telephone');
$table->string('email', 50)->unique();
$table->string('username', 50)->unique();
$table->string('password', 50);
$table->boolean('active')->default(FALSE);
$table->string('email_confirmation_code', 6);
$table->enum('notify', ['y', 'n'])->default('y');
$table->rememberToken();
$table->timestamps();
$table->index('username');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
对于 PSR-4 自动加载器用户 (composer.json):
将迁移文件夹保存在 classmap
数组中,不要将其包含在 autoload
头下的 psr-4 对象中.由于迁移的主类 Migrator 不支持命名空间.例如;
Keep the migrations folder inside classmap
array and do not include it inside psr-4 object under autoload
head. As migrations' main class Migrator doesn't support namespacing. For example;
"autoload": {
"classmap": [
"app/database/migrations"
],
"psr-4": {
"Acme\controllers\": "app/controllers"
}
}
然后运行:
php artisan clear-compiled
php artisan optimize:clear
composer dump-autoload
php artisan optimize
- 第一个清除所有已编译的自动加载文件.
- 第二次清除 Laravel 缓存(可选)
- Third 为命名空间类构建自动加载器.
- Fourth 优化了 Laravel 应用程序的各个部分,并为非命名空间类构建自动加载器.
从现在起,您将不必再次执行此操作,任何新的迁移都将正常工作.
From this time on wards, you will not have to do this again and any new migrations will work correctly.