Download the PHP package thedoctor0/laravel-factory-generator without Composer
On this page you can find all versions of the php package thedoctor0/laravel-factory-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-factory-generator
Laravel Factory Generator
[]()
Automatically generate factories from your existing models.
It will allow you to write tests containing your models much faster.
Installation
You can install the package via composer:
For Laravel 8.x and 9.x check the v1.3.2.
For Laravel 6.x and 7.x check the v1.2.5.
Usage
To generate all factories at once, simply run this artisan command:
It will find all models and generate test factories based on the database structure and model relations.
Example
Migration and Model
Generated Factory
Advanced usage
Selecting models
To generate a factory for only specific model or models, run the artisan command:
Overwriting existing factories
By default, generation will not overwrite any existing model factories.
You can force overwriting existing model factories by using the --force
option:
Customizing the output directory
By default, it will search recursively for models under the app/Models
directory.
If your models are within a different folder, you can specify this using --dir
option.
In this case, run the artisan command:
Customizing the namespace
If your models are within a different namespace, you can specify it using --namespace
option.
You just need to execute this artisan command:
Using recursive mode
By default, your model directory structure is not taken into account, even though it has subdirectories.
You can reflect it to database/factories
directory by using the --recursive
option:
Customizing the factory template
If you want you can customize the factory template to suit your needs.
To publish a factory template to resources/views/vendor/factory-generator/factory.blade.php
, run the artisan command:
License
The MIT License (MIT). Please see license file for more information.
All versions of laravel-factory-generator with dependencies
illuminate/support Version ^10.0|^11.0
illuminate/console Version ^10.0|^11.0
illuminate/filesystem Version ^10.0|^11.0