How to Create Blade File using Command in Laravel 11?

08-Jun-2024

.

Admin

How to Create Blade File using Command in Laravel 11?

Hi, Dev

In this brief post, I'll demonstrate how to create a view blade file in a Laravel 11 application using an artisan command. We will utilize the `make:view` artisan command to generate the blade file.

Laravel has recently released version 11, featuring a significant improvement: a new Artisan command option for creating Blade files. Now, you can effortlessly generate a view file in Laravel 11 by running the following simple command: `php artisan make:view welcome`. This command streamlines the process of creating Blade files using Artisan.

So, let's see the simple example below:

Example 1: Laravel 11 Create Blade File Command


Here, the below command will help you to create 'dashboard.blade.php' file. so, let's run it and check the output as well.

php artisan make:view dashboard

You can see the following output:

laravel-11-blade-file-cre-1

they will create new file as like the below:

resources/views/dashboard.blade.php

<div>

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

</div>

Example 2: Laravel 11 Create Blade File inside Directory Command

Here, the below command will help you to create 'index.blade.php' file in users folder. so, let's run it and check the output as well.

php artisan make:view users.index

You can see the following output:

laravel-11-blade-file-cre-2

they will create new file as like the below:

resources/views/users/index.blade.php

<div>

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

</div>

These commands really help us.

I hope it can help you...

#Laravel 11