Laravel make view blade template use Artisan Console

Tram Ho

1. Introduction

Artisan is the command line interface that comes with Laravel . It provides a number of useful commands to help you build your application. To view a list of all available Artisan commands, you can use the command:

We can create models and controllers using the following Artisan commands:

But how to create 1 View & Blade Templates with Artisan like below?

At a glance, there is an Artisan View package to handle this. But we want to create an Artisan Console like that, how to do it?

This article will guide you how to create Blade Template through the Artisan Console . php artisan make:view

2.Get started

  1. Create Commands: MakeView

    php artisan make:command MakeView

  2. Logic code that creates the view
  3. Registered in App / Console / Kernel

3.Test

  • Create a home.blade.php view in the default directory

    php artisan make:view home

  • Create a view ‘home.blade.php’ in the sub-view (‘pages’)

    php artisan make:view pages.home

Share the news now

Source : Viblo