Rambling my thoughts and experience

Laravel artisan commands for Generators

Posted by Shailesh Davara on July 21, 2015 | 2 Minute Read

I got sometime to play with laravel’s new version 5.1. There are lots of artisan commands for productivity and creating a code stub of laravel components from the command line.

I’m going to discuss make commands that generate a file in the laravel application with basic code stub

We can see all make command in the make section of the artisan command list:

  php artisan list

Generate a command class

  php artisan make:command nameofcommand

This command will generate new command file at app/Commands/nameofcommand.php

Generate a console command class

  php artisan make:console nameofclass

This command will generate new console command file at app/Console/Commands/nameofclass.php

Generate a resource controller class

  php artisan make:controller mycontroller

This command will generate new resource controller file at app/Http/Controllers/mycontroller.php

Generate an event class

  php artisan make:event myevent

This command will generate new event file at app/Events/myevent.php

Generate a job class

  php artisan make:job myjob

This command will generate new job file at app/Jobs/myjob.php

Generate an event listener class

  php artisan make:listener mylistener

This command will generate new event listener file at app/Listeners/mylistener.php

Generate a middleware class

  php artisan make:middleware mymiddleware

This command will generate new middleware file at app/Http/Middleware/mymiddleware.php

Generate a migration class

  php artisan make:migration newmigration

This command will generate new migration file at database/migrations/timestamp_newmigration.php (timestamp will be actual timestamp :) )

Generate a model class

  php artisan make:model mymodel

This command will generate new model file at app/mymodel.php

Generate a model class

  php artisan make:model mymodel

This command will generate new model file at app/mymodel.php

Generate a provider class

  php artisan make:provider myprovider

This command will generate new provider file at app/Providers/myprovider.php

Generate a request class

  php artisan make:request myrequest

This command will generate new request file at app/Http/Requests/myrequest.php

Generate a seeder class

  php artisan make:seeder myseeder

This command will generate new request file at database/seeds/myseeder.php

Few of the commands were available in the 4.2 version and few of them are introduced in the 5.1. Apart from this, you can get more info about command by following:

php artisan help commandname

Enjoy!!