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
Of course, you can pass in options like
--pest to generate an accompanying PHPUnit test or a pest test for the view respectively.
php artisan make:view items --test --pest