5
    <?php
use Illuminate\Database\Seeder;
use App\User;

class UsersTableSeeders extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
       User::create([
                'name'=>'prakash',
                'username'=>'prakash',
                'email'=>'[email protected]',
                'password'=> bycrypt('pokhrel'),
                'remember_token'=> str_random(10),
            ]);
    }
}

I don't understand why i receiving this error : [ReflectionException] Class UsersTableSeeders does not exist

2 Answers 2

10

Try composer dump-autoload command on your terminal.

Sign up to request clarification or add additional context in comments.

2 Comments

Weird why this works as i created a whole bunch of seeder classes prior to that and had no problems. I wonder if it happens when the default UserSeeder gets removed then added again at a later point (?)
Actually it DOES happen after you remove the seeder class and then add it again, you need to run the command in order to regenerate the autoload_classmap file which includes the seeder class.
3

Make sure you add the tests directory in your composer.json like this:

"autoload": {
    "classmap": [
        "tests"
     ]
}

Run "composer dump-autoload" and "php artisan optimize" in the root of your project in terminal.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.