How to Create Blade View File Using Artisan Command in Laravel 11?

Jun 15, 2024 | Laravel 11 Laravel


Hello Dev,

In this brief post, I'll demonstrate how to create a Blade view file using the Artisan command in a Laravel 11 application. Laravel version 11 introduces a convenient new feature: the ability to generate Blade files directly from the command line. To create a view file named "welcome.blade.php," simply execute the following Artisan command: `php artisan make:view welcome`. This enhancement streamlines the process of generating Blade views using Laravel's Artisan command.

Example 1: Laravel 11 Create Blade File Command

To create the `dashboard.blade.php` file using the Artisan command, execute the following in your Laravel 11 application:

php artisan make:view dashboard

This command will generate a new Blade view file named `dashboard.blade.php` in your `resources/views` directory. After running the command, you can check the output by navigating to the `resources/views` directory in your Laravel project. This approach allows you to efficiently create and manage Blade templates for your application's frontend views.

Laravel 11 Create Blade File using Command Example Tutorial

they will create new file as like the below:

resources/views/dashboard.blade.php
<div>
    <!-- The best way to predict the future is to create it. - Ratan Tata -->
</div>
Read Also: How To Import Large CSV File Into Database in Laravel 11? Example 2: Laravel 11 Create Blade File inside Directory Command

To create the `index.blade.php` file within the `users` folder using Laravel's Artisan command, run the following:

php artisan make:view users.index

Executing this command will generate a new Blade view file named `index.blade.php` specifically in the `resources/views/users` directory of your Laravel project. After running the command, you can verify the creation of the file by navigating to the `resources/views/users` directory. This method provides a straightforward way to organize and create Blade templates tailored for different sections or components within your application.

Laravel 11 Create Blade File using Command Example Tutorial 1

they will create new file as like the below:

resources/views/users/index.blade.php
<div>
    <!-- Dream big and work hard to make those dreams a reality. - Ratan Tata -->
</div>

Feel free to ask if you have any questions or need further clarification!



Tags :
#Laravel 11
#Laravel
ItErrorSolution.com

ItErrorSolution.com

"Hey there! I'm a full-stack developer and proud owner of ItErrorSolution.com, based right here in India. I love nothing more than sharing handy tips and tricks with my fellow developers through easy-to-follow tutorials. When it comes to coding, I'm all about PHP, Laravel, Angular, Vue, Node, JavaScript, jQuery, CodeIgniter, and Bootstrap – been hooked on them forever! I'm all about putting in the work and staying committed. Ready to join me on this journey to coding?"