1

Problem I'm currently facing to has been posted here already, yet none of them could solve my one.

I'm talking about database seeder located under url like http://HOSTNAME/laravelfiles/database/seeds/UsersTableSeeder.php. Its content is as follows:

<?php

use Illuminate\Database\Seeder;

class UsersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // What should be being done, it is being done here :)
    }
}

Having opened this file directly (by url given above the code), following error is printed:

Fatal error: Class 'Illuminate\Database\Seeder' not found in /var/www/laravelfiles/database/seeds/UsersTableSeeder.php on line 6

I found possible solution. Doesn't work for me:

  • composer dump-autoload

<?php

use Illuminate\Database\Seeder;

class UsersTableSeeder extends Seeder
{
}

NOTE: Even the code above produces the same error.

1 Answers1

1

You must run seeder class via command line, not browser. you should open your command line and change directory to laravel root folder. then you need to run command:

php artisan db:seed

and check your database.

for more info please check laravel documentation(Laravel Database Seeding)