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

Sovary December 31, 2023 1.18K
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

As the founder and passionate educator behind this platform, I’m dedicated to sharing practical knowledge in programming to help you grow. Whether you’re a beginner exploring Machine Learning, PHP, Laravel, Python, Java, or Android Development, you’ll find tutorials here that are simple, accessible, and easy to understand. My mission is to make learning enjoyable and effective for everyone. Dive in, start learning, and don’t forget to follow along for more tips and insights!. Follow him