Artisan command to generate views in Laravel
Laravel has all kinds of Artisan commands to let you generate boilerplate code for your application. For instance, you can generate a controller, model, migration, and so on using the Artisan command. But, there was no command to generate views in Laravel until now.
This changes with the release of Laravel 10.x. With this release, you can now generate Blade views using the make:view
Artisan command. Let’s see how.
To generate a view, you can use the following command.
php artisan make:view <view name>
So, if you want to create a view called items.blade.php
, you can do so by running the following command.
php artisan make:view items
This will create a view called items.blade.php
in the resources/views
directory.
Of course, you can pass in options like --test
and --pest
to generate an accompanying PHPUnit test or a pest test for the view respectively.
php artisan make:view items --test --pest
Like this article?
Buy me a coffee👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.