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
- Install (dev dependency):
composer require dedsec/laravel-autoseeder --dev
- (Optional) Publish config:
php artisan vendor:publish --provider="Dedsec\\LaravelAutoSeeder\\AutoSeederServiceProvider" --tag=config
- Generate seeders:
php artisan make:auto-seeders
- 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/Modelsor 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 migratefirst. - 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
--onlyand 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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dedsec/laravel-autoseeder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Testing Suite For Lumen like Laravel does.
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Symfony bundle to manage fixtures with Alice and Faker.
Additional plugin for fakerphp/faker that allows you to generate a random animal
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-28