API Reference

SeederRegistry

Singleton that collects seeders registered across all layers.

Xefi\LaravelOSDD\SeederRegistry is a singleton registered in the IoC container. It collects seeder class-strings pushed by layer service providers and exposes them to php artisan osdd:seed.

Namespace

use Xefi\LaravelOSDD\SeederRegistry;

Binding

The registry is bound as a singleton in the container by LaravelOSDDServiceProvider. You can resolve it directly if needed:

$registry = app(SeederRegistry::class);

Methods

push(int $priority, string ...$seeders): void

Appends one or more seeder class-strings to the registry at a given priority. Lower priority numbers execute first; seeders with equal priority maintain their registration order (stable sort).

Parameters:

ParameterTypeDescription
$priorityintExecution priority — lower numbers run first. Use 0 for the default order.
...$seedersstring (variadic)One or more fully-qualified seeder class names

Example:

$registry = app(SeederRegistry::class);
$registry->push(0, OrdersSeeder::class, OrderStatusSeeder::class);
$registry->push(-10, RolesSeeder::class); // runs before orders seeders
You should not call push() directly in most cases. Use LayerServiceProvider::loadSeeders() instead, which calls push() for you.

seeders(): array

Returns all seeder class-strings currently in the registry, sorted by ascending priority. Seeders with equal priority are returned in registration order (stable sort).

Returns: array<string>

Example:

$registry = app(SeederRegistry::class);

foreach ($registry->seeders() as $seederClass) {
    echo $seederClass . PHP_EOL;
}
// Functional\Users\Database\Seeders\RolesSeeder    (priority -10)
// Functional\Users\Database\Seeders\UsersSeeder    (priority 0)
// Functional\Orders\Database\Seeders\OrdersSeeder  (priority 0)

How osdd:seed Uses It

The osdd:seed command resolves the registry and calls db:seed --class=... for each entry in priority order:

// Simplified internals of SeedCommand
$registry = $this->laravel->make(SeederRegistry::class);

foreach ($registry->seeders() as $seederClass) {
    $this->call('db:seed', ['--class' => $seederClass]);
}