Get "PHP 8 in a Nuthshell" (Now with PHP 8.4)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

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.

Artisan command to generate views in Laravel

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
Learn the fundamentals of PHP 8 (including 8.1, 8.2, 8.3, and 8.4), the latest version of PHP, and how to use it today with my new book PHP 8 in a Nutshell. It's a no-fluff and easy-to-digest guide to the latest features and nitty-gritty details of PHP 8. So, if you're looking for a quick and easy way to PHP 8, this is the book for you.

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.

Comments?