ruzaik11/laravel-seeder-tracker
Composer 安装命令:
composer require ruzaik11/laravel-seeder-tracker
包简介
Track Laravel seeders execution like migrations with batch support and status management
README 文档
README
Track your Laravel seeders execution like migrations with batch support, execution time tracking, and comprehensive status management.
✨ Why Use Seeder Tracker?
In large Laravel applications, managing database seeders becomes complex:
- Duplicate executions can corrupt data or waste time
- No visibility into which seeders have run
- Performance issues go unnoticed
- Environment differences cause inconsistencies
Seeder Tracker solves these problems by bringing migration-like tracking to your seeders!
🚀 Features
- 📊 Migration-like tracking - Know exactly which seeders have run
- ⏱️ Performance monitoring - Track execution time and memory usage
- 🔄 Batch management - Group related seeder executions
- 🛡️ Duplicate prevention - Prevent accidental re-runs in production
- 📈 Rich analytics - Detailed performance insights and reporting
- 🎯 Environment-aware - Smart controls based on your environment
- 💾 Metadata storage - Store custom data from seeder results
- 🔍 Auto-discovery - Automatically find and track all project seeders
📦 Installation
Install via Composer:
composer require ruzaik11/laravel-seeder-tracker
Publish configuration and migrations:
php artisan vendor:publish --provider="Ruzaik\SeederTracker\SeederTrackerServiceProvider"
php artisan migrate
🎯 Quick Start
1. Create a Trackable Seeder
Replace Seeder with TrackableSeeder:
<?php namespace Database\Seeders; use Ruzaik\SeederTracker\Seeders\TrackableSeeder; use App\Models\User; class UsersTableSeeder extends TrackableSeeder { protected function seedData() { // Your seeding logic $users = User::factory(100)->create(); // Return metadata for tracking return [ 'users_created' => $users->count(), 'admin_users' => $users->where('is_admin', true)->count(), ]; } }
2. Run Your Seeders
php artisan db:seed --class=UsersTableSeeder
# ✅ Seeder UsersTableSeeder executed successfully in 1,234ms
3. Check Execution Status
php artisan seeder:status
📊 Seeder Execution Status
+------------------+-------------+------------------+-------+
| Seeder | Status | Executed At | Batch |
+------------------+-------------+------------------+-------+
| UsersTableSeeder | ✅ Executed | Dec 21, 2024 14:30 | 1 |
| ProductSeeder | ⏳ Pending | Not executed | N/A |
+------------------+-------------+------------------+-------+
Summary: 1/2 seeders executed
📋 Available Commands
Status Management
# Basic status php artisan seeder:status # Detailed view with performance metrics php artisan seeder:status --detailed # Reset specific seeder php artisan seeder:status --reset=UsersTableSeeder # Reset all tracking (with confirmation) php artisan seeder:status --reset-all
Performance Analytics
# Show performance insights php artisan seeder:performance # Limit results php artisan seeder:performance --limit=5
🔧 Advanced Usage
Environment-Aware Seeding
use Ruzaik\SeederTracker\Traits\SeederHelper; class ProductionDataSeeder extends TrackableSeeder { use SeederHelper; protected function seedData() { // Only run in specific environments return $this->runInEnvironments(['production', 'staging'], function () { // Production-specific seeding logic return ['production_data_created' => true]; }); } }
Performance Optimization
protected function seedData() { $startCount = $this->getTableCount('products'); // Batch insert for better performance Product::insert($this->generateProductData(1000)); return [ 'products_created' => $this->getTableCount('products') - $startCount, 'batch_size' => 1000, 'optimization' => 'batch_insert_used', ]; }
Transaction Safety
protected function seedData() { return DB::transaction(function () { // All seeding logic in transaction $categories = Category::createMany($this->categoryData()); $products = Product::createMany($this->productData()); return [ 'categories_created' => count($categories), 'products_created' => count($products), 'transaction_safe' => true, ]; }); }
⚙️ Configuration
Customize behavior in config/seeder-tracker.php:
return [ // Database table for tracking 'table' => 'seeder_tracking', // Enable automatic tracking 'auto_track' => true, // Prevent duplicate executions 'prevent_duplicates' => env('SEEDER_PREVENT_DUPLICATES', true), // Strict environments (always prevent duplicates) 'strict_environments' => ['production'], ];
📈 Performance Monitoring
Track seeder performance automatically:
php artisan seeder:performance
📊 Performance Summary
Total executions: 15
Average execution time: 1,247ms
Total time spent: 18.7s
Average memory usage: 12.3MB
🐌 Slowest Seeders
+------------------+----------------+-------------+------------------+
| Seeder | Execution Time | Memory Used | Executed At |
+------------------+----------------+-------------+------------------+
| ProductSeeder | 3,456ms | 25.4MB | Dec 21, 14:30 |
| UsersTableSeeder | 2,123ms | 15.7MB | Dec 21, 14:25 |
+------------------+----------------+-------------+------------------+
🏃 Fastest Seeders
+------------------+----------------+-------------+------------------+
| Seeder | Execution Time | Memory Used | Executed At |
+------------------+----------------+-------------+------------------+
| RoleSeeder | 45ms | 2.1MB | Dec 21, 14:20 |
| SettingSeeder | 67ms | 3.2MB | Dec 21, 14:22 |
+------------------+----------------+-------------+------------------+
🧪 Testing
The package includes comprehensive tests:
# Run tests composer test # Run with coverage composer test-coverage
📚 Examples
Check the examples/ directory for:
- Basic seeder implementation
- Advanced environment-aware seeding
- Performance optimization techniques
- Transaction handling patterns
🔧 Troubleshooting
See TROUBLESHOOTING.md for common issues and solutions.
📈 Development Journey
This package was developed over 3+ months with focus on:
- October 2024: Foundation and core architecture
- November 2024: Tracking logic and performance monitoring
- December 2024: Enhanced commands and comprehensive documentation
- January 2025: Community feedback and optimization
🤝 Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
📄 License
MIT License. See LICENSE for details.
👨💻 Credits
- Ruzaik Nazeer - Creator and maintainer
- Laravel Community - Inspiration and feedback
Built with ❤️ for the Laravel community
Website •
Email •
Packagist
ruzaik11/laravel-seeder-tracker 适用场景与选型建议
ruzaik11/laravel-seeder-tracker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 4, 最近一次更新时间为 2025 年 07 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「performance」 「migration」 「laravel」 「batch」 「artisan」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ruzaik11/laravel-seeder-tracker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ruzaik11/laravel-seeder-tracker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ruzaik11/laravel-seeder-tracker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
g4 application profiler package
CSS/Javascript Minificator, Compressor and Concatenator for TYPO3 - highly configurable frontend asset optimization for CSS/JS merging, minification and compression with optional body parsing, async/defer loading, inline output, data-ignore exclusions, SRI integrity validation/calculation, external
WordPress mu-plugin to remove jQuery Migrate from the list of jQuery dependencies and to allow jQuery to enqueue before </body> instead of in the <head>.
Store your language lines in the database, yaml or other sources
Create link to static resources with cache-breaking segment based on md5 of the file
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-03