PHPackages                             leandrodiogenes/laravel-test-factory-helper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. leandrodiogenes/laravel-test-factory-helper

ActiveLibrary[Testing &amp; Quality](/categories/testing)

leandrodiogenes/laravel-test-factory-helper
===========================================

Generate Laravel test factories from your existing models

v2.1.2(5y ago)0613MITPHPPHP ^7.2.5

Since Mar 26Pushed 5y agoCompare

[ Source](https://github.com/leandrodiogenes/laravel-test-factory-helper)[ Packagist](https://packagist.org/packages/leandrodiogenes/laravel-test-factory-helper)[ RSS](/packages/leandrodiogenes-laravel-test-factory-helper/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (4)Versions (23)Used By (0)

Laravel Test Factory Generator
------------------------------

[](#laravel-test-factory-generator)

`php artisan generate:model-factory`

This package will generate [factories](https://laravel.com/docs/master/database-testing#writing-factories) from your existing models so you can get started with testing your Laravel application more quickly.

### Example output

[](#example-output)

#### Migration and Model

[](#migration-and-model)

```
Schema::create('users', function (Blueprint $table) {
    $table->increments('id');
    $table->string('name');
    $table->string('username');
    $table->string('email')->unique();
    $table->string('password', 60);
    $table->integer('company_id');
    $table->rememberToken();
    $table->timestamps();
});

class User extends Model {
    public function company()
    {
        return $this->belongsTo(Company::class);
    }
}
```

#### Factory Result

[](#factory-result)

```
$factory->define(App\User::class, function (Faker\Generator $faker) {
    return [
        'name' => $faker->name,
        'username' => $faker->userName,
        'email' => $faker->safeEmail,
        'password' => bcrypt($faker->password),
        'company_id' => factory(App\Company::class),
        'remember_token' => Str::random(10),
    ];
});
```

### Install

[](#install)

Require this package with composer using the following command:

```
composer require --dev mpociot/laravel-test-factory-helper
```

### Usage

[](#usage)

To generate multiple factories at once, run the artisan command:

`php artisan generate:model-factory`

This command will find all models within your application and create test factories. By default, this will not overwrite any existing model factories. You can *force* overwriting existing model factories by using the `--force` option.

To generate a factory for specific model or models, run the artisan command:

`php artisan generate:model-factory User Team`

By default, this command will search under the `app` folder for models. If your models are within a different folder, for example `app/Models`, you can specify this using `--dir` option. In this case, run the artisan command:

`php artisan generate:model-factory --dir app/Models -- User Team`

### License

[](#license)

The Laravel Test Factory Helper is free software licensed under the MIT license.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~72 days

Recently: every ~33 days

Total

22

Last Release

2189d ago

Major Versions

0.5.0 → 1.0.02019-06-18

v1.3 → v2.0.02020-01-01

PHP version history (5 changes)0.1PHP &gt;=5.4.0

0.3.0PHP &gt;=5.6.0

1.0.0PHP &gt;=7.0

v2.0.0PHP ^7.2

v2.1.0PHP ^7.2.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ba6f23cdbc58437fa243a252549c73ecf1c5e91ecc81d14b5a72e368d0cbe24?d=identicon)[leandrodiogenes](/maintainers/leandrodiogenes)

---

Top Contributors

[![jasonmccreary](https://avatars.githubusercontent.com/u/161071?v=4)](https://github.com/jasonmccreary "jasonmccreary (25 commits)")[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (12 commits)")[![skeets23](https://avatars.githubusercontent.com/u/13846271?v=4)](https://github.com/skeets23 "skeets23 (11 commits)")[![jijoel](https://avatars.githubusercontent.com/u/3487641?v=4)](https://github.com/jijoel "jijoel (2 commits)")[![leandrodiogenes](https://avatars.githubusercontent.com/u/2463299?v=4)](https://github.com/leandrodiogenes "leandrodiogenes (2 commits)")[![edmandiesamonte](https://avatars.githubusercontent.com/u/11081512?v=4)](https://github.com/edmandiesamonte "edmandiesamonte (2 commits)")[![SvenSlijkoord](https://avatars.githubusercontent.com/u/11380389?v=4)](https://github.com/SvenSlijkoord "SvenSlijkoord (1 commits)")[![dweinerATL](https://avatars.githubusercontent.com/u/5572940?v=4)](https://github.com/dweinerATL "dweinerATL (1 commits)")[![ilvsx](https://avatars.githubusercontent.com/u/5467343?v=4)](https://github.com/ilvsx "ilvsx (1 commits)")[![Jeroen-G](https://avatars.githubusercontent.com/u/1116853?v=4)](https://github.com/Jeroen-G "Jeroen-G (1 commits)")[![Oussama-Tn](https://avatars.githubusercontent.com/u/787632?v=4)](https://github.com/Oussama-Tn "Oussama-Tn (1 commits)")[![dontfreakout](https://avatars.githubusercontent.com/u/1829574?v=4)](https://github.com/dontfreakout "dontfreakout (1 commits)")

---

Tags

laravelfactorytests

### Embed Badge

![Health badge](/badges/leandrodiogenes-laravel-test-factory-helper/health.svg)

```
[![Health](https://phpackages.com/badges/leandrodiogenes-laravel-test-factory-helper/health.svg)](https://phpackages.com/packages/leandrodiogenes-laravel-test-factory-helper)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[mpociot/laravel-test-factory-helper

Generate Laravel test factories from your existing models

933635.2k2](/packages/mpociot-laravel-test-factory-helper)[laravel/ui

Laravel UI utilities and presets.

2.7k134.9M601](/packages/laravel-ui)[thedoctor0/laravel-factory-generator

Automatically generate Laravel factories for your models.

214997.4k1](/packages/thedoctor0-laravel-factory-generator)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
