mpociot/laravel-test-factory-helper
Larablocks Analysis
mpociot/laravel-test-factory-helper works with Laravel 6 and 7 (latest release v2.1.0, Mar 2, 2020), all past end of life (the last on Sep 6, 2022): no more fixes, even for security.
Laravel 5 in earlier releases.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- Supports only Laravel 6 and 7, past end of life since Sep 6, 2022
- No release in the last 12 months (last: Mar 2, 2020)
- 1,611 downloads a month (needs 10,000)
- 928 GitHub stars (at least 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: Mar 2, 2020.
- No releases in the last 12 months.
- First released: Mar 26, 2016.
- Monthly downloads: 1,611, up 32% from six months ago.
- 19 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.
| Install | |
|---|---|
composer require mpociot/laravel-test-factory-helper |
|
| Latest Version: | v2.1.0 |
| PHP: | ^7.2.5 |
| Laravel: | 6 · 7 |
| Older releases: | 5 |
| License: | MIT |
| Last Updated: | Jan 18, 2024 |
| Links: | GitHub · Packagist |
Laravel Test Factory Generator
php artisan generate:model-factory
This package will generate factories from your existing models so you can get started with testing your Laravel application more quickly.
Example output
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->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
Require this package with composer using the following command:
composer require --dev mpociot/laravel-test-factory-helper
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
The Laravel Test Factory Helper is free software licensed under the MIT license.
Related Packages
Automatically generate Laravel factories for your models.
The goal of this package is to enable the rapid creation of objects for the purp...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v2.1.0 | ^7.2.5 | ^6.0| | MIT | |
| v2.0.1 | ^7.2 | ^6.0 | MIT | |
| v2.0.0 | ^7.2 | ^6.0 | MIT | |
| v1.3 | >=7.0 | ^5.5| | MIT | |
| 1.2 | >=7.0 | ^5.5| | MIT | |
| 1.1.2 | >=7.0 | ^5.5 | MIT | |
| 1.1.1 | >=7.0 | ^5.5 | MIT | |
| 1.1.0 | >=7.0 | ^5.5 | MIT | |
| 1.0.2 | >=7.0 | ^5.5 | MIT | |
| 1.0.1 | >=7.0 | ^5.5 | MIT | |
| 1.0.0 | >=7.0 | ^5.5 | MIT | |
| 0.5.0 | >=5.6.0 | ^5.0 | MIT | |
| 0.4.0 | >=5.6.0 | ^5.0 | MIT | |
| 0.3.1 | >=5.6.0 | 5.0.x| | MIT | |
| 0.3.0 | >=5.6.0 | 5.0.x| | MIT | |
| 0.2.1 | >=5.4.0 | 5.0.x| | MIT | |
| 0.2.0 | >=5.4.0 | 5.0.x| | MIT | |
| 0.1.2 | >=5.4.0 | 5.0.x| | MIT | |
| 0.1.1 | >=5.4.0 | 5.0.x| | MIT | |
| 0.1 | >=5.4.0 | 5.0.x| | MIT |