New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

laravel-shift/factory-generator

Generate factories from existing models
965,738 48
Install
composer require laravel-shift/factory-generator
Latest Version:v2.3
PHP:^8.1
Laravel:10 – 13
Older releases:9
License:MIT
Last Updated:Jul 14, 2026
Links: GitHub  ·  Packagist
Maintainer: jasonmccreary

Laravel Model Factory Generator

This package generates model factories from existing models using the new class-based factories introduced in Laravel 8.

Installation

You may install this package via composer by running:

composer require --dev laravel-shift/factory-generator

The package will automatically register itself using Laravel's package discovery.

Usage

This package adds an artisan command for generating model factories.

Without any arguments, this command will generate model factories for all existing models within your Laravel application:

php artisan generate:factory

Similar to Laravel, this will search for models within the app/Models folder, or if that folder does not exist, within the app folder.

To generate factories for models within a different folder, you may pass the --path option (or -p).

php artisan generate:factory --path=some/Other/Path

To generate a factory for a single model, you may pass the model name:

php artisan generate:factory User

By default nullable columns are not included in the factory definition. If you want to include nullable columns you may set the --include-nullable option (or -i).

php artisan generate:factory -i User

Attribution

This package was original forked from Naoray/laravel-factory-prefill by Krishan König.

It has diverged to support the latest version of Laravel and to power part of the automation by the Tests Generator.

Contributing

Contributions should be submitted to the master branch. Any submissions should be complete with tests and adhere to the Laravel code style. You may also contribute by opening an issue.

Related Packages

league/factory-muffin

The goal of this package is to enable the rapid creation of objects for the purp...

15,906,405 533
rymanalu/factory-generator

Laravel 5 Model Factory Generator.

8,006 17
laravel/browser-kit-testing

Provides backwards compatibility for BrowserKit testing in the latest Laravel re...

10,656,994 515
chekote/noun-store

Store and work with Nouns

98,035 8
jeffochoa/factory-stories

Create model factory stories in Laravel 5.*

66,557 78

Version History

Version Released PHP Laravel License
v2.3 ^8.1 ^10.0|^11.0|^12.0|^13.0 MIT
v2.2 ^8.1 ^10.0|^11.0|^12.0 MIT
v2.1 ^8.1 ^10.0|^11.0 MIT
v2.0 ^8.1 ^10.0|^11.0 MIT
v1.0 ^9.0|^10.0 MIT