Laravel 10 - How to Create a View Using an Artisan Command

Sovary December 31, 2023 440
1 minute read

In this article, we'll explore the process of creating a view file in Laravel 10 using the Artisan command. We'll provide examples and a step-by-step tutorial on how to command Artisan to generate views in Laravel 10. This post will give example of creating views using the Artisan command.

This example is all about creating a Blade file in Laravel 10 using the command line. It's a simple way to understand how to use 'php artisan make: view' command works in Laravel 10 for generating a view file. Throughout this process, you will gain knowledge on how to create a view file in Laravel 10. I will assist you to creating a Blade file in Laravel 10 using the terminal by following the steps below.

Example 1: Create Blade File Command - Laravel 10

Open the terminal and run below command command will help you create the user.blade.php file. Let's run it and check the output as well.

php artisan make:view user

And you will find a new file like the one below in directory resources/views/user.blade.php

<div>
    <!-- Live as if you were to die tomorrow. Learn as if you were to live forever. - Mahatma Gandhi -->
</div>

Example 2: Create Blade File Inside Folder Command - Laravel 10

Suppose we want to create a blade file in directory users with file name index.blade.php. Let's run following command to create file.

php artisan make:view users.index

The above command will create a file index.blade.php in directory resources/views/users/index.blade.php

<div>
    <!-- He who is contented is rich. - Laozi -->
</div>

You may also like...

Laravel  PHP  Laravel 10 
Author

Founder of CamboTutorial.com, I am happy to share my knowledge related to programming that can help other people. I love write tutorial related to PHP, Laravel, Python, Java, Android Developement, all published post are make simple and easy to understand for beginner. Follow him