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

theFinalArbiter's avatar

Seeding at production fails

I have deployed my laravel app to a shared hosting enviroment for some feedback. It has SSH and git. Things work just fine until now. Im unable to seed the database.

Running the commands

php artisan migrate:refresh
php artisan db:seed

works fine on my localhost (windows)

On the linux server however

-securelve_sh-4.1$ php artisan db:seed

  [ReflectionException]
  Class UsersTableSeeder does not exist

My code shouldnt be the problem (`?) but here it is. DatabaseSeeder.php

<?php

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

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

        $this->call(UsersTableSeeder::class);
        $this->call(TradesTableSeeder::class);

        Model::reguard();
    }
}

UsersTableSeeder.php

<?php

use Illuminate\Database\Seeder;

use Faker\Factory as Faker;

class UsersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::table('users')->delete();
        
        $faker = Faker::create();

        foreach(range(1,10) as $index) {
            DB::table('users')->insert([
                'firstname' => $faker->firstName,
                'lastname' => $faker->lastName,
                'email' => $faker->email,
                'password' => bcrypt('secret'),
            ]);
        }
    }
}

I have checked all filenames cases. And the gitignores seems to allow for the seeding stuff. How can I proceed the debugging? Any Ideas?

0 likes
3 replies
bestmomo's avatar
Level 52

Try a composer dumpautoload to regenerate autoload.

1 like
theFinalArbiter's avatar

Thanks @bestmomo! That did the trick! However I dont understand why. I havnt added any new vendor stuff and have never needed to that before. Those helpers, like php artisan make:seeder do they also fix the autoloading automatically for the new files?

Please or to participate in this conversation.