Harvest is a seeder component 🚟 that helps you to bundle automation run by Taz🌪️.
composer require goldfinch/harvestIf you haven't used Taz🌪️ before, taz file must be presented in your root project folder cp vendor/goldfinch/taz/taz taz
Create new harvest
php taz make:harvestList all available harvesters
php taz harvestRun specific harvest
php taz harvest myharvestRun all available harvesters
php taz harvest:allLet's create a new harvest calling Pages that will handle Page Mill which will generate fake records for us by firing a single command.
php taz make:harvest Pages
# What [short name] does this harvest need to be called by? : pagesAfter creating new harvest, we need to run dev/build to update harvest list
php taz dev/buildNow our harvest pages should be available in the harvest list, let's check that:
php taz harvestAs we decide that our harvest will manage mill factory, we need to create one. For more info about mills please refer to goldfinch/mill
php taz make:mill Page
# What [class name] does this mill is going to work with? : PageLet's modify our Mill by adding some placeholder data:
namespace App\Mills;
use Goldfinch\Mill\Mill;
class PageMill extends Mill
{
public function factory(): array
{
return [
'Title' => $this->faker->catchPhrase(),
'Content' => $this->faker->paragraph(20),
];
}
}We also need to make sure that Millable trait is added to Page class as it states in goldfinch/mill.
namespace {
use Goldfinch\Mill\Traits\Millable;
use SilverStripe\CMS\Model\SiteTree;
class Page extends SiteTree
{
use Millable;
private static $db = [];
}
}Now we can go back to our PageHarvest that was created by Taz in the first step and add our mill to it.
namespace App\Harvest;
use Goldfinch\Harvest\Harvest;
class PagesHarvest extends Harvest
{
public static function run(): void
{
\Page::mill(10)->make();
}
}Now our harvest is ready to rock along with Taz. By firing our harvest, we should get 10 newly generated pages in admin site tree.
php taz harvest pagesThis module plays nicely with mill factory goldfinch/mill
The MIT License (MIT)