Search code examples
phplaravellumenlaravel-artisan

Lumen 5.6 - php artisan db:seed got error 'Class DatabaseSeeder does not exist'


I'm trying to seed with Lumen 5.6.3 and executed the command: php artisan db:seed.

Then I got error, saying

In Container.php line 767:
Class DatabaseSeeder does not exist

In my database/seeds directory, DatabaseSeeder.php does exist. I've just copied the source in Lumen's official document and the source is like below.

<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //
    }
}

I've googled many times to solve this error and of course tried composer dump-autoload, composer dump-autoload -o, composer dump-autoload --no-dev several times and the situation has never changed.

I also checked my composer/autoload_classmap.php and there is 'DatabaseSeeder' => $baseDir . '/database/seeds/DatabaseSeeder.php' so I looks like autoload does work correctly.

I really appreciate any advices or comments. Thank you.


Solution

  • I set a wrong value for bootstrap/app.php.

    I set like the below.

    require_once __DIR__.'/../../vendor/autoload.php';
    

    After I modified this part like following, I could run db:seed command correctly.

    require_once __DIR__.'/../vendor/autoload.php';