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

deeperdata's avatar

Unable to run php artisan db:seed due to missing class

I'm using Lumen and working through a 12 month-old tutorial.

While attempting to run php artisan db:seed, I'm getting the following error:

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

However I created the Models sub-directory and Quote.php within that directory. Here is that code:

<?php

# app/Models/Quote.php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

final class Quote extends Model  
{

}

Within database/seeds I have two files: QuoteTableSeeder.php & the default DatabaseSeeder.php. I added $this->call('QuoteTableSeeder'); to the run() method of DatabaseSeeder.php.

Here are the contents of QuoteTableSeeder.php:

<?php

# database/seeds/QuoteTableSeeder.php

use App\Models\Quote;
use Illuminate\Database\Seeder;

class QuoteTableSeeder extends Seeder
{
    public function run()
    {
        Quote::create([
            'text' => 'Success is going from failure to failure without losing your enthusiasm',
            'author' => 'Winston Churchill',
            'background' => '1.jpg'
        ]);

    }
}

I have already ran composer dump-autoload which fixed a previous error but now causes the above-mentioned issue.

What am I doing wrong?

0 likes
1 reply
usama.ashraf's avatar

@deeperdata make sure you have something like this in your composer.json:

"autoload": {
        "classmap": [
            "database",
            "app/Models"
        ],
        "psr-4": {
            "App\\": "app/",
            "App\\Models\\": "app/Models",
            "App\\Controllers\\": "app/Controllers"
        },
........

Then run these:

php artisan clear-compiled 
composer dump-autoload
php artisan optimize

You changed the default namespace for the models and now have a custom folder essentially. This has to be added to the 'autoload' section for composer dump-autoload to have any meaningful effect on autoload_classmap.php.

Please or to participate in this conversation.