Most Useful Laravel Artisan Make Commands lists with parameters
If you think that you are like most of
the other developers, and you try to find list of Laravel artisan make commands
for your development process through different websites. You may not find a
single resource on web which has all essentially useful command list for Laravel
artisan make commands. I am also one of you before I listed all command from
different resource and I also knew that it is a waste of time to juggling
through different sites for finding it. That’s why I compiled a list of most
essential useful artisan make commands for Laravel in a single note for save
time of you my friend and all other developers.
Laravel has very useful and awesome sets of artisan commands,
that probably the most often used are with make:xxx –
like make:model or make:migration and so on. But
do you know about artisan make commands? And, do you know about their
parameters which may help to make the code even quicker and speedy?
Here in bellow is the most important artisan
make commands list for Laravel Development, which I have found useful.
Most Useful Laravel Artisan Make Commands lists with parameters
First, when you use this command php artisan list which
gives us all the commands, like this:
make:auth Scaffold basic login and registration views and routes
make:command Create a new Artisan command
make:controller Create a new controller class
make:event Create a new event class
make:job Create a new job class
make:listener Create a new event listener class
make:mail Create a new email class
make:middleware Create a new middleware class
make:migration Create a new migration file
make:model Create a new Eloquent model class
make:notification Create a new notification class
make:policy Create a new policy class
make:provider Create a new service provider class
make:request Create a new form request class
make:seeder Create a new seeder class
make:test Create a new test class
But it doesn’t give you an information in brief about the
parameters or options for these above list of commands. So I make a list and want
to make an overview of each of them here bellow, starting with the most often
used.
For that, you will dive into actual code of the framework,
inside /vendor/laravel/framework/src/Illuminate folder, and
will check what options and undocumented features and importance you have for
each command.
1. make:migration
Create a new migration file for database process.
Example usage:
php artisan make:migration create_student_table
Parameters:
--create=Table
The table to be created.
--table=Table
The table to migrate.
--path=Path
The location where you should be create the migration file.
2. make:seeder
Create a new database seeder class.
Example usage:
php artisan make:seeder StudentTableSeeder
Parameters: none.
3. make:controller
This command generate a new controller file in app/Http/Controllers folder.
Example usage:
php artisan make:controller StudentController
Parameters:
--resource
The controller will contain a method for each of the available
resource operations – index(), create(), store(), show(), edit(), update(),
destroy().
--model=Photo
If you are trying to use route model binding and would like the
resource controller’s methods to type-hint a model instance.
4. make:model
Create a new Eloquent model class.
Example usage:
php artisan make:model Student
Parameters:
--migration
Create a new migration file for the model.
--controller
Create a new controller for the model.
--resource
It indicates that if the generated controller should be a
resource controller.
Yes, you got it right, you can do it like this:
php artisan make:model Student --migration --controller --resource
Or even shorter you may use like:
php artisan make:model Student -mcr
5. make:request
Create a new form request class which is store in app/Http/Requests folder.
Example usage:
php artisan make:request StoreStudent
Parameters: none.
6. make:middleware
Create a new middleware class for different processes.
Example usage:
php artisan make:middleware CheckFees
Parameters: none.
7. make:policy
Create a new policy class.
Example usage:
php artisan make:policy StudentPolicy
Parameters:
--model=Photo
The model that the policy applies to.
8. make:auth
Example usage:
php artisan make:auth
Scaffold basic login and registration views and routes with
default authentication.
Parameters:
--views
Only scaffold the authentication views.
--force
Overwrite existing views by default.
9. make:command
Create a new Artisan command.
Example usage:
php artisan make:command SendEmails
Parameters:
--command=Command
The terminal command that should be assigned.
10. make:event
Create a new event class.
Example usage:
php artisan make:event FeesPayment
Parameters: none.
11. make:job
Create a new job class.
Example usage:
php artisan make:job SendReminderEmail
Parameters:
--sync
Indicates that job should be synchronous.
12. make:listener
Create a new event listener class.
Example usage:
php artisan make:listener SendPaymentNotification
Parameters:
--event=Event
The event class being listened for.
--queued
Indicates the event listener should be queued.
13. make:mail
Create a new email class.
Example usage:
php artisan make:mail PaymentSuccess
Parameters:
--markdown
Create a new Markdown template for the mailable.
14. make:notification
Create a new notification class.
Example usage:
php artisan make:notification FeesPaid
Parameters:
--markdown
Create a new Markdown template for the notification.
15. make:provider
Create a new service provider class.
Example usage:
php artisan make:provider RiakServiceProvider
Parameters: none.
16. make:test
Create a new test class.
Example usage:
php artisan make:test StudentTest
Parameters:
--unit
Create a unit (or, otherwise, feature) test.
You want to hire me for Laravel Project, click here!