Download the PHP package rymanalu/factory-generator without Composer
On this page you can find all versions of the php package rymanalu/factory-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rymanalu/factory-generator
More information about rymanalu/factory-generator
Files in rymanalu/factory-generator
Package factory-generator
Short Description Laravel 5 Model Factory Generator.
License MIT
Homepage https://github.com/rymanalu/factory-generator
Informations about the package factory-generator
Laravel 5 Model Factory Generator
This package offers a lazy way to create a new model factory files, since Laravel (< 5.5) have no Artisan command to generate it.
Installation
First, install this package via the Composer package manager:
Next, you should add the FactoryGeneratorServiceProvider
to the providers
array of your config/app.php
configuration file:
Now, you should be able to generate a new model factory file by executing php artisan make:factory
command.
Usage
php artisan make:factory
accept one argument: the model class name with the namespace. Make sure the model is already exists before executing this command.
Example:
The command will generate a file named PostFactory.php
in /path/to/your-laravel-project/database/factories
directory:
This command also using the fillable array of the model and pair all of fillable values to $faker->word
as default (you can change it to the proper Faker Formatters or other value later) in the generated model factory.
For example, if the App\Post
has fillable array like this:
Then, the command will generate the PostFactory.php
like this: