dedsec/laravel-autoseeder 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

dedsec/laravel-autoseeder

Composer 安装命令:

composer require --dev dedsec/laravel-autoseeder

包简介

Automatically generate realistic database seeders for Laravel models including relationships.

README 文档

README

Automatically generate realistic database seeders for Laravel models, including relationships.

Quick start

  1. Install (dev dependency):
composer require dedsec/laravel-autoseeder --dev
  1. (Optional) Publish config:
php artisan vendor:publish --provider="Dedsec\\LaravelAutoSeeder\\AutoSeederServiceProvider" --tag=config
  1. Generate seeders:
php artisan make:auto-seeders
  1. Run seeders:
php artisan db:seed

Requirements

  • PHP: >= 7.4
  • Laravel: >= 8.0
  • Supported DB: MySQL, PostgreSQL, SQLite, SQL Server

Usage & options

Run the generator (common options shown):

php artisan make:auto-seeders [--path=app/Models] [--limit=10] [--only=User,Post] [--force] [--quiet] [--verbose]

Options (summary):

  • --path — models directory (default: app/Models)
  • --limit — number of records per model (default: 10)
  • --only — comma-separated model class basenames to process (e.g. User,Post)
  • --force — overwrite existing generated seeders
  • --quiet — suppress output (useful for CI)
  • --verbose — show debug details

Examples

  • Generate seeders for all models (10 records each):
php artisan make:auto-seeders
  • Generate 5 records per model:
php artisan make:auto-seeders --limit=5
  • Generate seeders for specific models (User and Post):
php artisan make:auto-seeders --only=User,Post
  • Use a custom models directory:
php artisan make:auto-seeders --path=app/CustomModels
  • Force overwrite of any previously generated seeders:
php artisan make:auto-seeders --force

Key features

  • Automatic model discovery (scans app/Models or provided path)
  • Type-aware data generation (respect column types/lengths, including full enum support)
  • Foreign-key aware seeding and ordering
  • Relationship detection (belongsTo, hasMany, belongsToMany, morphs, etc.)
  • Unique & composite-unique constraint handling
  • Polymorphic support and two-phase seeding for circular deps

Configuration (defaults)

After publishing, edit config/autoseeder.php. example defaults:

return [
	'models_path' => 'app/Models',
	'records_limit' => 10,
	'skip_tables' => [],
	'date_format' => 'Y-m-d H:i:s',
	'string_max_length' => 255,
	'enable_strict_types' => true,
	'enable_relationship_validation' => true,
	'enable_uniqueness_guards' => true,
];

Troubleshooting

  • "No Eloquent models found" — ensure models are in the path or pass --path.
  • "Table doesn't exist" — run php artisan migrate first.
  • Foreign key / unique constraint errors — confirm relationships and migration state.

For verbose debug output use:

php artisan make:auto-seeders --verbose

Best practices

  • Use this package in development and testing only.
  • Consider committing generated seeders if they are part of test fixtures.
  • Generate related models together to preserve referential integrity.
  • Use --only and reasonable limits when working with large schemas.

License

MIT

dedsec/laravel-autoseeder 适用场景与选型建议

dedsec/laravel-autoseeder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「faker」 「testing」 「laravel」 「Relationships」 「seeder」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 dedsec/laravel-autoseeder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dedsec/laravel-autoseeder 我们能提供哪些服务?
定制开发 / 二次开发

基于 dedsec/laravel-autoseeder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-28