mmacdonald's avatar

Migrations won't run because "blank" class doesn't exist.

I'm extremely confused... I have an (essentially) fresh install of Laravel. All I've really done is create my models and migrations. Now I'm trying to run the migrations and I keep getting the error:

[Symfony\Component\Debug\Exception\FatalThrowableError] Class '' not found

Which makes no sense to me. It successfully creates the "migrations" table and then fails to run even he first migration. The part that confuses me though is that the Class is '' (blank)... it doesn't have a name! How can i be missing a blank class? Where is it even trying to call this non-existent class?

I've tried composer dump-autoload php artisan cache:clear php artisan optimize php artisan clear-compiled

Not necessarily in that specific order... and a bunch of combinations therein.

Error log looks like:

[2017-10-19 15:57:48] local.ERROR: Class '' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class '' not found at /home/vagrant/__/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:417)
[stacktrace]
#0 /home/vagrant/__/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(168): Illuminate\\Database\\Migrations\\Migrator->resolve('0_create_users_...')
#1 /home/vagrant/__/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(146): Illuminate\\Database\\Migrations\\Migrator->runUp('/home/vagrant/W...', 1, false)
#2 /home/vagrant/__/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(95): Illuminate\\Database\\Migrations\\Migrator->runPending(Array, Array)
...
#17 /home/vagrant/__/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#18 {main}
"} 

Ignore the path containing "___" I just changed out the project name, for NDA reasons...

This is all running locally on an out-of-the-box Homestead setup.

All the advice I've found for related issues is basically "composer dump-autoload" which runs fine... but doesn't fix the issue. Which I'm assuming is because the class is blank and there is some other underlying issue here.

The only thing I can think of is changing the names of the migrations to just use a numerical index instead of a timestamp... I'm not really sure why that would matter though. All the class names still match their respective migration names. For example the first migration is 0_create_users_table.php and it looks like this:

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}

Any input at this point would be greatly appreciated! I'm not sure what I've messed up... but I'm completely stumped as to how I should proceed.

Thanks!

0 likes
1 reply
mmacdonald's avatar
mmacdonald
OP
Best Answer
Level 2

Hmm... so I solved it, but I'm going to leave this up in case some other person stumbles upon it...

Today I learned that Laravel has to have the timestamp at the start of the migration name! I re-added the timestamps and adjusted the seconds to order them how I wanted instead of just an index. Ran composer dump-autoload . and then it migrated perfectly.

Yay!

To clarify:

I had renamed my migrations like this:


1_migration

2_migration

...

and now I've renamed them to:


2017_10_19_100001_migration

2017_10_19_100002_migration

...

Please or to participate in this conversation.