CodeIgniter v4.5 API

Seeder
in package

Class Seeder

Table of Contents

Properties

$config  : Database
An instance of the main Database configuration
$db  : BaseConnection
Database Connection instance
$DBGroup  : non-empty-string
The name of the database group to use.
$forge  : Forge
Database Forge instance.
$seedPath  : string
Where we can find the Seed files.
$silent  : bool
If true, will not display CLI messages.
$faker  : Generator|null
Faker Generator instance.

Methods

__construct()  : mixed
Seeder constructor.
call()  : mixed
Loads the specified seeder and runs it.
faker()  : Generator|null
Gets the Faker Generator instance.
run()  : void
Run the database seeds. This is where the magic happens.
setPath()  : $this
Sets the location of the directory that seed files can be located in.
setSilent()  : $this
Sets the silent treatment.

Properties

$config

An instance of the main Database configuration

protected Database $config

$DBGroup

The name of the database group to use.

protected non-empty-string $DBGroup

$seedPath

Where we can find the Seed files.

protected string $seedPath

$silent

If true, will not display CLI messages.

protected bool $silent = false

$faker

Faker Generator instance.

private static Generator|null $faker = null

Methods

__construct()

Seeder constructor.

public __construct(Database $config[, BaseConnection|null $db = null ]) : mixed
Parameters
$config : Database
$db : BaseConnection|null = null

call()

Loads the specified seeder and runs it.

public call(string $class) : mixed
Parameters
$class : string
Tags
throws
InvalidArgumentException

faker()

Gets the Faker Generator instance.

public static faker() : Generator|null
Return values
Generator|null

run()

Run the database seeds. This is where the magic happens.

public run() : void

Child classes must implement this method and take care of inserting their data here.

Tags
codeCoverageIgnore

setPath()

Sets the location of the directory that seed files can be located in.

public setPath(string $path) : $this
Parameters
$path : string
Return values
$this

setSilent()

Sets the silent treatment.

public setSilent(bool $silent) : $this
Parameters
$silent : bool
Return values
$this

        
On this page

Search results