承接 strawberrydev/wimd 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

strawberrydev/wimd

最新稳定版本:v2.1.4-alpha

Composer 安装命令:

composer require strawberrydev/wimd

包简介

Where Is My Data - A Laravel seeder monitoring package

README 文档

README

Cover

Latest Version on Packagist Total Downloads License

Introduction

Have you ever wondered where your data is while seeding? Me too. That's why there's WIMD (Where Is My Data), a Laravel package that enhances your database seeding process with monitoring. It provides real-time tracking of seeding performance, detailed metrics, and insightful reporting to help you optimize your database seeding operations.

Warning

This is the first release and not a stable version. It is meant to showcase the current state of the project and its progress. Updates will be made.
Some features don't work yet and will be properly implemented in future updates.

Requirements

  • PHP 8.1+
  • Laravel 9.0+

Installation

You can install the package via composer:

composer require strawberrydev/wimd

Or for alpha version

composer require strawberrydev/wimd:"dev-main"

Configuration

Publish the configuration file using:

php artisan vendor:publish --tag=wimd-config

This will create a config/wimd.php file where you can customize the package behavior.

Usage

DatabaseSeeder

<?php

namespace Database\Seeders;

use Wimd\Template\WimdDatabaseSeeder;

class DatabaseSeeder extends WimdDatabaseSeeder
{
    public function run()
    {
        $this->call([
            UserSeeder::class,
            CategoriesSeeder::class,
            ProductsSeeder::class,
            TagsSeeder::class,
            ProductTagSeeder::class,
            UserDetailsSeeder::class,
            ReviewsSeeder::class,
        ]);

        // Optional
        $this->displayWimdReport();
    }
}

showcase

Use this line if you want to manually display the report (not shown by default unless using the specific command):

$this->displayWimdReport();

Seeder

Extend Wimd\Template\WimdSeeder instead of Laravel's Seeder:

<?php

namespace Database\Seeders;

use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Wimd\Template\WimdSeeder;

class UserSeeder extends WimdSeeder
{
    protected function prepare(): void
    {
        $this->totalItems = 1000;
        $this->fullItems = 1000000;
        $this->lightItems = 250;
        $this->batchSize = 77;
    }

    protected function seed(): void
    {
        $admin = [
            'name' => 'Admin User',
            'email' => 'admin@example.com',
            'password' => Hash::make('password'),
            'created_at' => now(),
            'updated_at' => now(),
        ];

        $this->insertItem('users', $admin);

        $this->createWithFactory(User::class, $this->totalItems - 1);
    }
}

Advanced Usage

Using the Built-in Batch Methods

batchInsert()

$this->batchInsert('users', $usersArray, $batchSize);

insertItem() and insertItemAndGetId()

$this->insertItem('users', $userData);

createWithFactory()

$this->createWithFactory(User::class, 50);

License

The MIT License (MIT). Please see License File for more information.

Footer

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-31