laravel/framework · error · InvalidArgumentException
Method [run] missing from {class}
Error message
Method [run] missing from {class} What it means
Seeder.__invoke() requires every seeder class to define a run() method — that is the contract entry point the framework calls. If method_exists($this, 'run') is false, InvalidArgumentException is thrown before any work begins. The exception names the offending class so you can locate it.
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 bd6b5437e6)
Solutions
- Add a public function run(): void { ... } method to the seeder class named in the message.
- Check for typos: the method must be exactly 'run' (case-sensitive).
- Ensure you are calling the intended concrete seeder, not an abstract base class.
- Run composer dump-autoload to clear a stale class map pointing at a stub.
Example fix
// before
namespace Database\Seeders;
class UserSeeder extends Seeder
{
public function seed(): void
{
User::factory(10)->create();
}
}
// after
namespace Database\Seeders;
class UserSeeder extends Seeder
{
public function run(): void
{
User::factory(10)->create();
}
} Defensive patterns
Strategy: validation
Validate before calling
$class = \Database\Seeders\UserSeeder::class;
if (! method_exists($class, 'run')) {
throw new \LogicException("{$class} must implement run()");
}
$this->call($class); Type guard
/** @param class-string $seeder */
function isValidSeeder(string $seeder): bool
{
return method_exists($seeder, 'run');
} Prevention
- Every seeder class must define public function run().
- Use php artisan make:seeder to get the correct stub.
- Do not invoke abstract/base seeder classes directly.
When it happens
Trigger: Calling $this->call(SomeSeeder::class) or invoking a seeder (via db:seed or DatabaseSeeder) where SomeSeeder has no run() method — e.g. a class extending Seeder that only defines a helper method, or a typo (run vs Run, or a class used as a base/abstract without being meant to seed).
Common situations: Forgot to add run() after generating a seeder; renamed run() to something else; an abstract base seeder class being invoked directly; a seeder class that only defines call() invocations inside the wrong method name; namespace/class autoload mismatch loading an empty stub.
Related errors
- Transactions Manager has not been set.
- Callback must be a callable, callback array, or a 'Class@met
- Auth guard [{$name}] is not defined.
- Auth driver [{$config['driver']}] for guard [{$name}] is not
- Authentication user provider [{$driver}] is not defined.
AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06).
Data as JSON: /data/errors/e867acadebd7ad78.json.
Report an issue: GitHub.