Skip to content
Yo-An Lin edited this page May 14, 2017 · 2 revisions

Seed Script is used to create a set of base data that helps you to setup the application. for example, you might need to create the city records for the city name selector, then you can define a CitySeed that creates the City names into the database.

Defining Seed Script

To define a basedata seed script:

<?php

namespace AuthorBooks;

use Maghead\Runtime\BaseSeed;

class MySeed extends BaseSeed { 
    public static function seed() {
       Model\Author::create([ 'name' => 'John' ]);
       Model\Book::create([ 'name' => 'Programming PHP' ]);
    }
}

Then update your config file by adding the class name of the data seed class:

seeds:
- AuthorBook::MySeed

To execute the seed scripts, run the command below:

php bin/maghead seed

Clone this wiki locally