Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

frenksjr's avatar

php artisan migrate:rollback error

Hello, when i typed command php artisan migrate:rollback i got error, that class does not exist. But it is existing.

<?php

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

class CreateWebsiteTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('website', function (Blueprint $table) {
            $table->increments('id_site');
            $table->string('');
            $table->timestamps();
        });
    }

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

0 likes
13 replies
frenksjr's avatar

php artisan migrate:rollback

[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'CreateWebsiteTable' not found

veve286's avatar

drop your database and try this command 'php artisan migrate'

1 like
StuffedGoat's avatar

Try this: composer dump-autoload

I assume that the "framework" does not "know" about your new class.

13 likes
misterzapp's avatar

Just in case this helps someone, composer dump-autoload fixed this for me as well.

2 likes
vipin's avatar

composer dump-autoload worked for me.

edgreenberg's avatar

'composer dump-autoload' worked for me. I did not need 'composer require doctrine/dbal'

SmithWebster's avatar

No! What are you talking about! You should do this only -> composer dump-autoload and try again. It helps.

Revolution's avatar

using folders for migration table organization and testing.

had undefined index problem as above. composer dump-autload, deleting migrations table, restarting vagrant, lots of other attempts all failed.

simple solution: on php artisan migrate:rollback --path=/database/migrations/folder

pass the path parameter to the rollback method. that's the solution if composer dump-autoload doesn't work for you on rollback or reset due to undefined index error.

amielantonio's avatar

composer dump-autoload alone did not worked for me.

if you happen to rename your classes and did it without using the terminal, you need to check the autoload-static.php and autoload-classmap.php for the Migration name and its corresponding migration table.

Ex. CreateEmpTable => {date}_create_emps_table. is giving me an error since Emp is singular while emps is plural. This caused my error. so I simply change them in the specified files and then run composer dump-autoload. then migrate.

Please or to participate in this conversation.