- What does coderello/laravel-populated-factory do?
- It generates Laravel model factories that are already populated with real data pulled from your existing database, instead of leaving you with empty Faker-based stubs. It inspects your models and their relationships to produce ready-to-use factory definitions with minimal setup. The result is realistic test data and seeders that match the shape and values of your actual schema.
- How do I install laravel-populated-factory?
- Install it through Composer with composer require coderello/laravel-populated-factory, typically as a dev dependency since it is a development and seeding aid. After installing, follow the package README for the artisan command that generates a populated factory for a given model. Run composer show coderello/laravel-populated-factory to confirm the resolved illuminate/support constraint before you commit, because the intake record for this package does not document its Laravel version range.
- Does it require an existing database with data in it?
- Yes. The package reads from a populated database and turns those rows into factory definitions, so a fresh empty schema gives it very little to work with. The more representative your existing data, the more realistic the generated factories and any seeders built from them. Seed a development or staging copy first if you do not want to point it at anything sensitive.
- Which Laravel and PHP versions does laravel-populated-factory support?
- Release 1.1.0 added PHP 8 support, which is the only compatibility signal documented in the intake record. PHP 8 compatibility is not the same as Laravel version support, so read composer.json at the 1.1.0 tag and diff it against 1.0.x to see whether the PHP constraint was widened to ^7.4|^8.0 or replaced with ^8.0 only, and which illuminate/support range is declared. Treat the release note as a compatibility floor rather than a proven Laravel version guarantee.
- Does it handle model relationships like belongsTo, hasMany and many-to-many?
- It inspects models and their relationships to produce factory definitions, which is the core of what makes the generated factories usable in real tests. Verify the relationship types your schema actually uses in a sandbox model before relying on them, since the intake record contains no metadata confirming coverage of every relation type. Where a relation is not generated automatically, you can extend the produced factory file by hand like any other hand-written factory.
- Can I use the generated factories in seeders and not just tests?
- Yes. A generated factory is a standard Laravel factory class, so it works anywhere factories are supported, including database seeders, test setUp methods and local demo data. Because the definitions reflect real database values, seeders built from them look like plausible production data. Keep in mind that factory-generated records still flow through your models, so observers, events and validation will fire as usual.
- Is it safe to point laravel-populated-factory at a production database?
- It only reads schema and sample rows to build factory definitions, but you should still avoid running it directly against production. Use a scrubbed staging copy or a subset dump so real personal data never ends up committed in factory files or fixtures. Generated factories are code, so treat them like any artifact that could ship live values into your repository.
- How does it compare to Faker-based factories or schema-driven model generators?
- Faker-based factories produce synthetic values that may not match your real domain, such as status codes, enum values or slug formats, while this package copies the shape of your actual data. Schema-driven generators focus on deriving migrations and models from the database, whereas this one focuses on populated factory definitions you can drop into your test suite. They are complementary, and many teams generate factories once and then maintain them by hand.
- Is coderello/laravel-populated-factory actively maintained, and what is the bus factor?
- The intake record shows a 1.1.0 release adding PHP 8 support but no data on maintainer count, release cadence or changelog depth beyond a single line. That points to a likely small or single-maintainer package, so plan for the possibility that you own fixes downstream. Check the repository commit history, open issues and Packagist download stats before making it a long-term dependency of your test tooling.
- How do I verify compatibility before using it in a Laravel 9+ or PHP 8.1 app?
- Do a constraint audit first: read composer.json at the 1.1.0 tag and diff require against 1.0.x to see whether PHP 8 support was added additively or substitutively. Then install it in a throwaway app pinned to your target framework version and run composer why-not coderello/laravel-populated-factory to surface conflicts explicitly. Finally, exercise the package public surface in a small test harness before rolling it into shared tooling.