- How do I generate seeders for all tables in my Laravel database?
- Run `php artisan iseed` without arguments. The package automatically detects all tables and generates a seeder class for each. For Laravel 8+, no additional configuration is needed due to auto-discovery.
- Can I use iseed to create seeders for specific tables only?
- Yes. Use CSV notation to specify tables: `php artisan iseed users,products`. This generates separate seeders for each table while skipping others. Combine with `--classnameprefix` to avoid conflicts.
- Does orangehill/iseed support Laravel 13 and PHP 8.1+?
- Yes, the package officially supports Laravel 8–13 and PHP 8.0+. For Laravel 13, use the latest stable version (no extra steps required). Check the [GitHub repo](https://github.com/orangehill/iseed) for version-specific notes.
- How do I handle sensitive data (e.g., passwords, emails) in generated seeders?
- Avoid seeding sensitive data directly. Use `--where` to filter production data (e.g., `php artisan iseed users --where='id < 10'`) or pre-process seeders with scripts (e.g., `str_replace` for emails). Never commit real PII to version control.
- Will iseed work with PostgreSQL or MySQL foreign keys?
- Yes, but with caveats. For PostgreSQL, use `--reset-sequences` to handle auto-increment fields. MySQL foreign keys are preserved, but test seeders thoroughly. Large tables may require `--chunksize` to avoid constraint violations during bulk inserts.
- Can I integrate iseed into a CI/CD pipeline for automated seeder generation?
- Absolutely. Trigger `php artisan iseed` in your pipeline (e.g., post-migration) to generate seeders from a staging DB. Use `--database=staging` to target a specific connection. Pair with Laravel’s `php artisan migrate:fresh --seed` for full workflows.
- How do I customize the generated seeder class names or file structure?
- Use `--classnameprefix` or `--classnamesuffix` to modify names (e.g., `php artisan iseed users --classnameprefix=Test_`). For deeper customization, override the default stub templates in `resources/views/vendor/iseed` or publish them with `php artisan vendor:publish --tag=iseed.stubs`.
- What’s the best way to test seeders generated by iseed?
- Use PestPHP or PHPUnit to verify seeders. Generate seeders from a controlled DB (e.g., `php artisan iseed --database=test`), then assert data integrity with `DatabaseMigrations` or snapshot testing. For large datasets, test with `--max=100` first.
- Does iseed support non-default database connections (e.g., MySQL replica)?
- Yes. Specify the connection with `--database=connection_name` (e.g., `php artisan iseed --database=mysql_replica`). This works for read replicas, PostgreSQL, or any connection defined in `config/database.php`. Test connection-specific quirks (e.g., timezones) manually.
- Are there alternatives to orangehill/iseed for Laravel seeder generation?
- For Laravel, alternatives include `laravel-shift/database-seeder-generator` (similar CLI tool) or manual `DB::table()->get()` in custom seeders. For non-Laravel PHP, consider `doctrine/dbal` or custom scripts. However, iseed is the most Laravel-native option with built-in Artisan integration and stub templating.