laravel/framework · error · InvalidArgumentException

Method [run] missing from '.get_class($this)

Error message

Method [run] missing from '.get_class($this)

What it means

Seeder::__invoke (the entry point invoked by the db:seed command and DatabaseSeeder) checks method_exists($this, 'run') and throws InvalidArgumentException if the seeder class does not define a run() method. Every concrete seeder must implement run(); anonymous/abstract seeders or stubs that omit it fail at invocation time.

Source

Thrown at src/Illuminate/Database/Seeder.php:180

    public function setCommand(Command $command)
    {
        $this->command = $command;

        return $this;
    }

    /**
     * Run the database seeds.
     *
     * @param  array  $parameters
     * @return mixed
     *
     * @throws \InvalidArgumentException
     */
    public function __invoke(array $parameters = [])
    {
        if (! method_exists($this, 'run')) {
            throw new InvalidArgumentException('Method [run] missing from '.get_class($this));
        }

        $callback = fn () => isset($this->container)
            ? $this->container->call([$this, 'run'], $parameters)
            : $this->run(...$parameters);

        if (isset(class_uses_recursive(static::class)[WithoutModelEvents::class])) {
            $callback = $this->withoutModelEvents($callback);
        }

        return $callback();
    }
}

View on GitHub (pinned to e0f6eb3518)

Solutions

  1. Add a public function run(): void to the seeder class.
  2. If the seeder is a base/abstract class meant only to be extended, do not register it in DatabaseSeeder::run() / --class.
  3. Make sure the --class argument names a concrete, runnable seeder.

Example fix

// before
class OrdersSeeder extends \Illuminate\Database\Seeder
{
    public function seed()
    {
        // ...
    }
}

// after
class OrdersSeeder extends \Illuminate\Database\Seeder
{
    public function run(): void
    {
        // ...
    }
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (! method_exists($seederInstance, 'run')) {
    throw new \InvalidArgumentException(get_class($seederInstance).' must implement run().');
}
$seederInstance(...);

Type guard

function isValidSeeder(object|string $seeder): bool
{
    return method_exists(is_string($seeder) ? $seeder : $seeder, 'run');
}

Prevention

When it happens

Trigger: Registering a class in DatabaseSeeder::$callers (or passing --class=Foo) where Foo extends Seeder but does not declare a run() method; instantiating and invoking a seeder class that only has internal helper methods.

Common situations: Naming the seeder method something other than run() (e.g. seed(), execute()); abstract base seeder accidentally added to the call list; copy-paste from a generator that left the run() body as a TODO without the method signature; class renamed but method signature not updated.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/c691b1412d73f6c3. Report an issue: GitHub.