简体   繁体   English

Laravel 4迁移错误

[英]Laravel 4 Migration Error

I'm getting the following error when trying to create migrations for my laravel 4 installation. 尝试为laravel 4安装创建迁移时出现以下错误。 The file gets created but it outputs the following error. 文件已创建,但输出以下错误。

Created Migration: 2014_07_06_073213_create-users-table
Generating optimized class loader
Compiling common classes
{"error":
{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'ClassPreloader\\Command\\PreCompileCommand' not found","file":"\/home\/name123\/domain.com\/laravel\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Console\/OptimizeCommand.php","line":113}}[warehouse]

$ php artisan migrate:make create-users-table

It doesn't seem that there are any other people having the same problem. 似乎没有其他人遇到相同的问题。

Also getting this error when i commit the migration 当我提交迁移时也会出现此错误

{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to a member function increments() on a non-object","file":"\/home\/dandel26\/danieldelcore.com\/laravel\/app\/database\/migrations\/2014_06_29_092641_create_users_table.php","line":15}}

Thanks in advance. 提前致谢。

In you're migration you have the function up. 在迁移过程中,您可以使用该功能。 In this function there will be something like: 在此功能中,将出现以下内容:

Schema::create('users', function (Blueprint $table) {
    $table->increments('id');
});

It would seem that you did not do define the callback with the variable $table. 似乎您没有使用变量$ table定义回调。 Please add Blueprint $table and it should work. 请添加Blueprint $table ,它应该可以工作。

In that case remember to import the right namespaces: 在这种情况下,请记住导入正确的名称空间:

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM