Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Factory Generator

Factory Generator Laravel Package

laravel-shift/factory-generator

Generate Laravel model factories automatically from your existing database schema. This Laravel Shift package inspects table columns and writes realistic Faker-based definitions, saving hours when adding tests or seed data to legacy applications.

View on GitHub
Deep Wiki
Context7

Generate factories from existing models

Frequently asked questions about Factory Generator
How do I install laravel-shift/factory-generator?
Install it as a dev dependency with composer require --dev laravel-shift/factory-generator:^2.3. There is no service provider configuration, no migrations, and no schema changes required. After installation you run one or more Artisan commands and review the generated files under database/factories. Because it is dev-only, it does not affect production autoloading or your deployed artifact.
Does laravel-shift/factory-generator support Laravel 13?
Version 2.3 adds Laravel 13.x compatibility, which is the gating item for teams on or moving to Laravel 13. However, the compatibility work is new, so treat it as declared compatible rather than proven at scale. Laravel 13 is a fresh major and third-party schema introspection layers often lag on grammar and type changes. Validate generated output against your own schema before adopting it repo-wide.
What Artisan command generates factories from existing models?
The package exposes Artisan commands such as generate:factory that introspect your Eloquent models and the underlying table schema. They then emit standard Laravel factory classes into database/factories. The output is ordinary framework-consumed code, so you review and commit it like hand-written source.
Should I install laravel-shift/factory-generator as a dev dependency only?
Yes. It is a developer-time code generation tool, not a runtime dependency, and sits entirely outside the request lifecycle. Installing it with require --dev keeps it out of your production dependency surface and deploy artifact. The generated factory classes are committed source and do not depend on the package at runtime.
How does the factory generator handle enums, JSON columns, casts, and polymorphic relations?
These are common sources of subtly wrong output, so generated factories should be treated as a first-pass scaffold. Column-to-Faker mappings, enum handling, JSON and array columns, ULID and UUID keys, polymorphic relations, and unique constraints all need review. Generate into a scratch path first, diff against existing factories, and correct mappings before committing. Then add relationship seeding and states manually.
Which database drivers does laravel-shift/factory-generator support?
The package introspects the schema through an underlying introspection and DBAL dependency chain, so driver support depends on that chain and on Laravel's schema grammar. The published evaluation flags the validated MySQL, Postgres, and SQLite matrix as an open question. Confirm your primary driver matches before relying on the output, and validate against the same driver your CI uses so generated types reflect production columns.
Can laravel-shift/factory-generator overwrite my existing factories?
You should not let it overwrite hand-written factories. For models that already have factories, generate into a scratch path and diff the results instead. This is also the recommended approach when backfilling a legacy application where some factories already exist. Only commit generated files after correcting Faker mappings and adding the states you need.
Is laravel-shift/factory-generator a replacement for Laravel's make:factory?
No. It complements the framework's native make:factory command and your existing hand-written factories rather than replacing them. The value is bulk-generating a realistic first draft from an existing database schema, which saves time in legacy applications or when adding seed data and tests. Native make:factory still creates an empty factory stub for you to fill in by hand.
What are the risks of using generated factories in tests?
The main risk is codegen fidelity: subtly wrong output produces unrealistic or colliding test data that fails quietly. Unique constraints, enums, JSON columns, and polymorphic relations are the usual trouble spots. The blast radius is low, though, because the package never ships to production and its output is committed source, so you can delete generated files and hand-edit to recover.
Is laravel-shift/factory-generator actively maintained?
It is single-vendor open source from Laravel Shift with an issue-driven backlog and no SLA. That is acceptable for a dev-only tool but not for anything load-bearing in CI. Before adopting it, check the maintainer's release cadence over the last 12 months and whether open issues affect your schema patterns. Also ask whether an explicit support policy ties v2.x to Laravel 13's support window.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect