Laravel Most Useful Command's Lists With Parameters Example

  • 05-09-2022
  • 1814
  • Laravel 9
  • Haresh Chauhan

Most useful laravel artisan make commands lists with parameters, we will discuss all the example commands that make a class in with some parameter and also with some argument and class name and short tricks how to use in our application and create a class in our application I will explain in this laravel artisan tutorial.

Laravel's most useful command lists with parameters example I will explain in this tutorial and I have given command example, you can just copy or follow the command and just give your class name as you wish to create with the class name.

This laravel command helps you to create all the class which is currently available in laravel, For all the command engaged with the made class, you must use make before you define which class you want to create then after we will give the class name.

1. PHP ARTISAN MAKE:MIGRATION

Create a simple migration file with the given name.

php artisan make:migration create_student_table

Define table name with new migration create with the new table.

--create=Table

Define table name along with new migration, to getting edit your exists table.

--table=Table

Generate your migrate file on a specific path, you must need first create a directory.

--path=Path

Create new migration for creating a student table.

php artisan make:migration create_student_table --create=student

Create a migration file for the edit existing student table.

php artisan make:migration edit_student_table --table=student

Create a migration file in a specific path.

php artisan make:migration edit_student_table --table=student --path=database/migrations/student

2. PHP ARTISAN MAKE:CONTROLLER

Create a student controller.

php artisan make:controller StudentController

Create a student controller in a specific path folder.

php artisan make:controller Admin/StudentController

Create a student controller with the full resource.

php artisan make:controller StudentController --resource

Create a student controller with the full resource and import the model name also or specify the model name.

php artisan make:controller StudentController --resource --model=Photo

3. PHP ARTISAN MAKE:MODEL

Create student model.

php artisan make:model Student

Create a student model with migration.

php artisan make:model Student --migration

Create a student model with migration and controller.

php artisan make:model Student --migration --controller

Create a student model with migration and resource controller.

php artisan make:model Student --migration --controller --resource

You can also use this short command to create model migration and resource controller create together.

php artisan make:model Student -mcr

4. PHP ARTISAN MAKE:MIDDLEWARE

Create check fees middleware.

php artisan make:middleware CheckFees

5. PHP ARTISAN MAKE:SEEDER

Create student table seeder.

php artisan make:seeder StudentTableSeeder

Run specific seeder with the helper of the class parameter.

php artisan db:seed --class=StudentTableSeeder

Seed all the create seeder together to database using command.

php artisan db:seed

6. PHP ARTISAN MAKE:REQUEST

Create student request, Handel HTTP Req.

php artisan make:request StudentRequest

Create student request Handel class in a specific path folder.

php artisan make:request Admin/StudentRequest

7. PHP ARTISAN MAKE:AUTH

Make default auth in the laravel system.

php artisan make:auth

Only scaffold the authentication views in the laravel app.

php artisan make:auth --views

Overwrite existing views and auth by default.

php artisan make:auth --force

8. PHP ARTISAN MAKE:JOB

Create a new job class.

php artisan make:job SendReminderEmail

To indicate that job should be synchronous.

php artisan make:job SendReminderEmail --sync

To indicate that job should be synchronous as well as job creation in a specific folder path.

php artisan make:job Admin/SendReminderEmail --sync

9. PHP ARTISAN MAKE:EVENT

Create a new event class.

php artisan make:event FeesPayment

Create a new event class with a specific folder path.

php artisan make:event User/FeesPayment

10. PHP ARTISAN MAKE:MAIL

Create a new mail class.

php artisan make:mail NotificationMail

Create a mailable class with a markdown template.

php artisan make:mail NotificationMail --markdown

11. PHP ARTISAN MAKE:PROVIDER

Create a new service provider.

php artisan make:provider AppConfigServiceProvider

Create a new service provider with a specific folder path.

php artisan make:provider Config/AppConfigServiceProvider

12. PHP ARTISAN MAKE:POLICY

Create a new policy class.

php artisan make:policy StudentPolicy

Create a new policy class with a specific model class define.

php artisan make:policy StudentPolicy --model=Photo

13. PHP ARTISAN MAKE:COMMAND

To create a new artisan command.

php artisan make:command DatabaseBackup

The terminal command should be assigned in the command class.

php artisan make:command DatabaseBackup --command=Command

14. PHP ARTISAN MAKE:LISTENER

Create a new event lister class.

php artisan make:listener UserNotification

The listening class listens for a specific event.

php artisan make:listener UserNotification --event=Event

This indicates that the event listener should be queued.

php artisan make:listener UserNotification --event=Event --queued

15. PHP ARTISAN MAKE:NOTIFICATION

Create a new notification class.

php artisan make:notification PaymentReceived

Create a new notification class with a markdown template.

php artisan make:notification PaymentReceived --markdown

16. PHP ARTISAN MAKE:TEST

Create a new test class.

php artisan make:test UserTest

Create a unit (or, otherwise, feature) test.

php artisan make:test UserTest --unit
Conclusion :

This laravel artisan command tutorial covered almost commands for making classes, also I have explained how to create a specific class on a specific folder path, and I have an example in this tutorial of all the commands with parameters.


We always thanks to you for reading our blogs.


dharmesh-image

Dharmesh Chauhan

(Swapinfoway Founder)

Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us

haresh-image

Haresh Chauhan

(Co-Founder)


We Are Also Recommending You :