How to Create Blade Files Using Artisan Command in Laravel 11?
Introduction :
Laravel 11 has introduced a new feature that allows you to create Blade view files using the make:view
Artisan command. This command streamlines the process of generating view files, saving you time and effort.
Example 1 : Creating a Simple Blade File
To create a basic Blade file in Laravel 11, use the following command:
This command will generate a welcome.blade.php
file in the resources/views
directory.
php artisan make:view welcome
Example 2 : Detailed Example
Let’s create a dashboard.blade.php
file using the make:view
command :
php artisan make:view dashboard
After running this command, you will find the newly created file at:
resources/views/dashboard.blade.php
Here’s what the dashboard.blade.php
file might look like :
Example 3 : Creating a Blade File Inside a Directory
You can also create Blade files within specific directories. For example, to create a Blade file in the users
directory, use the following command:
php artisan make:view users.index
This command will create an index.blade.php
file inside the users
folder.
After running this command, you will find the file at:
resources/views/users/index.blade.php
Here’s what the users/index.blade.php
file might look like:
Conclusion :
Using the php artisan make:view
command in Laravel 11 is a straightforward way to generate Blade files. It simplifies the process and helps you organize your views efficiently.
By following these examples, you can quickly create Blade files for your Laravel applications. Happy coding!