This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Laravel Generator: Automatically generate Laravel Framework files from a CLI command.

dev-master 2020-06-30 16:57 UTC

This package is auto-updated.

Last update: 2021-09-29 02:37:20 UTC


The Laravel Generator is a Laravel CLI command which aim is to help the development process of Laravel applications by providing some convenient code-generation capabilities.

At the moment, this package is capable of generating the following:

  • Models - with eloquent relations
  • Migrations - with custom field types and foreign keys relations
  • Factories - with proper faker types
  • Seeders

This package was forked from reliese/laravel and it was improved to support more features. Also, I'm using the package kitloong/laravel-migrations-generator to support migration generation.

How does it work?

This package expects that you are using Laravel 5.1 or above. You will need to import the daniloesser/laravel-generator package via composer:

composer require daniloesser/laravel-generator


Add the service provider to your config/app.php file within the providers key:

// ...
'providers' => [
     * Package Service Providers...

// ...

Configuration for local environment only

If you wish to enable generators only for your local environment, you should install it via composer using the --dev option like this:

composer require daniloesser/laravel-generator --dev

Then you'll need to register the provider in app/Providers/AppServiceProvider.php file.

public function register()
    if ($this->app->environment() == 'local') {

Custom configuration

Add the cli-generator.php configuration file to your config directory and clear the config cache:

php artisan vendor:publish --tag=cli-generator
php artisan config:clear


  • Invoke the generator:
php artisan code:generate
  • You can also specify the connection:
php artisan code:generate --connection=mysql
  • You will be prompted for which tables you want to scaffold from a list. You can pass more than one, separating them by a comma:
E.G: cities,states,countries
  • Additionally, you can inform a Model sub-folder to create the files in a specific folder/namespace:
E.G: Payment
  • After finishing Models generation, you will be prompted for migrations and factories generation as well.


For now, this package only supports MySQL databases.

Some customization is possible. Just check options inside cli-generator file.