code-8
code-8

Reputation: 58662

ReflectionException - Class name does not exist in Laravel 5.0

I have a little problem trying to seed my comments table. I'm 100% sure that I have the Class CommentTableSeeder.php in my /database/seeds directory.


CommentTableSeeder.php

<?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class CommentTableSeeder extends Seeder {

    public function run()
    {
        DB::table('comments')->delete();

        Comment::create(array(
            'author' => 'Chris Sevilleja',
            'text' => 'Look I am a test comment.'
        ));

        Comment::create(array(
            'author' => 'Nick Cerminara',
            'text' => 'This is going to be super crazy.'
        ));

        Comment::create(array(
            'author' => 'Holly Lloyd',
            'text' => 'I am a master of Laravel and Angular.'
        ));
    }

}

Then when I run : php artisan db:seed

I kept getting

enter image description here

I've also try running composer update and run : php artisan db:seed - still get the same result.

Any hints / help will be much appreciated !

Upvotes: 1

Views: 3316

Answers (1)

Tim Lewis
Tim Lewis

Reputation: 29278

You need to run

composer dump-autoload

to fix this error. What this does, among other things, is refreshes the list of classes available to your application.

In this case, while the class did exist in the right location, it was unavailable in your autoloaded class list, and thus returning a Not Found error.

Upvotes: 2

Related Questions