定制 goldfinch/harvest 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

goldfinch/harvest

最新稳定版本:v2.0.2

Composer 安装命令:

composer require goldfinch/harvest

包简介

Harvest is a seeder component that helps you to bundle automation run by Taz

README 文档

README

Silverstripe Version Package Version Total Downloads License

Harvest is a seeder component 🚟 that helps you to bundle automation run by Taz🌪️.

Install

composer require goldfinch/harvest

Available Taz commands

If 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:harvest

List all available harvesters

php taz harvest

Run specific harvest

php taz harvest myharvest

Run all available harvesters

php taz harvest:all

Use Case example

Let's create a new harvest calling Pages that will handle Page Mill which will generate fake records for us by firing a single command.

1. Create new harvest

php taz make:harvest Pages
# What [short name] does this harvest need to be called by? : pages

After creating new harvest, we need to run dev/build to update harvest list

php taz dev/build

Now our harvest pages should be available in the harvest list, let's check that:

php taz harvest

2. Create new mill

As 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? : Page

Let'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 = [];
    }
}

3. Prepare your harvest

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();
    }
}

4. Use harvest

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 pages

Recommendation

This module plays nicely with mill factory goldfinch/mill

License

The MIT License (MIT)

统计信息

  • 总下载量: 495
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 11
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固