- How do I install and use laravel-csv-seeder in a Laravel app?
- Install it with composer require --dev jeroenzwart/laravel-csv-seeder, then publish its config file if you need to change defaults. You create one seeder class per dataset that extends the package's base CSV seeder class, point it at your CSV file and target table, and run it with php artisan db:seed --class=YourSeeder. There are no migrations and no schema changes, so it fits entirely inside database/seeders/ and is easy to remove later.
- Does jeroenzwart/laravel-csv-seeder support Laravel 11 and Laravel 12?
- The last tagged release was in September 2023, before Laravel 11 and 12 shipped, so support should be verified rather than assumed. Check the composer.json constraints in the package to confirm which Laravel and PHP versions are admitted, and test the seeder in a branch before relying on it. If the constraints are loose, pin the package version in composer.json so a future major bump cannot happen silently.
- How do I set the CSV delimiter or handle the header row?
- Delimiters are configurable, so you can handle comma, semicolon or tab separated exports without rewriting the seeder. Header handling maps CSV columns to table columns by header order, which means your column ordering in the file must match the intended insert order. There is no explicit column mapping beyond that ordering, so rename or reorder columns in the CSV if they do not line up with the table.
- Can I truncate a table before seeding from a CSV file?
- Yes, the package offers optional pre-seed table truncation, which is convenient for repeatable fixtures and demo data. Treat it as a footgun rather than a convenience: a single config line can wipe a table if the seeder is accidentally run against the wrong environment. Add an explicit environment guard in the seeder class instead of relying on documentation alone.
- How does laravel-csv-seeder handle large CSV files and chunked inserts?
- Rows are inserted in chunks rather than one statement per row, and version 1.6.3 was a patch specifically targeting chunked inserts, so pin at least that version. Check whether chunk size is configurable and keep it under your driver's bind-parameter ceiling, since MySQL caps around 65,535 placeholders per statement and Postgres around 32,767. For very large files, benchmark a full import on a staging database before trusting it with data anyone depends on.
- What happens if a CSV row is malformed or a chunk fails mid-insert?
- The package is deliberately narrow: it offers no per-cell validation, no type coercion and no error-row reporting, so bad data can land in the table or be skipped without a clear signal. Version 1.6.3 fixed issues with chunked inserts, which implies earlier 1.6.x releases could write incomplete or misaligned row sets without raising an exception. Confirm whether chunks run inside a transaction so you know if a mid-chunk failure rolls back or leaves a partial commit, and validate your CSV before seeding.
- Can I hash sensitive column values when seeding from a CSV?
- Yes, the package includes a hashing feature for columns that should not be stored in plaintext, which is useful for user fixtures and demo accounts. Remember that the hashing happens at seed time, so the CSV itself still contains the original values. Keep those flat files out of the repository and treat them as sensitive data regardless of what the package does.
- Is laravel-csv-seeder safe to use in production?
- As a dev-only seeding tool it carries very low risk: it is never loaded on a web request, adds no service or schema, and is fully reversible. The moment you use it to load production reference data or backfill rows, it becomes a write-path dependency and inherits concerns about silent partial writes, missing validation and table truncation. Decide explicitly which mode you are in; if it is dev and test only, most production integrity questions do not apply.
- What license does laravel-csv-seeder use?
- GitHub reports the license as NOASSERTION, which means the repository's actual license must be confirmed before commercial adoption. Check the LICENSE file and the license field in composer.json against your legal requirements. Treat this as a hard gate rather than a formality, because an unclear license can block adoption later.
- What are the alternatives to laravel-csv-seeder for importing CSV data?
- For simple spreadsheet-shaped data, a hand-written seeder using fgetcsv plus inserts is the closest alternative and gives you full control over validation and error reporting. For richer imports with column mapping, validation and queued processing, a package like maatwebsite/excel is a better fit. Choose laravel-csv-seeder when the job is exactly loading a clean CSV into a table and you do not need mapping or per-row error handling.