Create views, including "resource" views, using console commands.
Quickly create views and view resources from the Artisan console, saving a surprising amount of time., (*1)
Creating views is as easy as:, (*2)
php artisan make:view user // creates --> index, create, show, edit views in the resources/views/user directory php artisan make:view user.index // creates --> resources/views/user/index.blade.php
Using something other than blade
templates?, (*3)
php artisan make:view user.index -e twig // creates --> resources/views/index.twig
Want to use a view path you specified in config/view.php
?, (*4)
// If your config/view file looks like this: 'paths' => [ resource_path('views'), resource_path('my-custom-view-folder') ], // Then just pass the key you want to use, like this: php artisan make:view user.index -p 1 // creates --> resources/my-custom-view-folder/index.blade.php
To get started, use composer to require this package:, (*5)
composer require bencomeau/artisan-make-view --dev
Then simply register
the package's Service Provider in your app/Providers/AppServiceProvider.php
file:, (*6)
Note: Laravel
5.5
and above uses Package Auto-Discovery; if you are using Laravel>= 5.5
it is not necessary to manually add the service provider as shown below., (*7)
public function register() { if ($this->app->environment('local')) { $this->app->register(\BenComeau\ArtisanMakeView\ArtisanMakeViewServiceProvider::class); } }
And you're ready to quickly generate views!, (*8)
To list all command options, (*9)
php artisan make:view --help
Make a single view by name, in dot
notation, (*10)
php artisan make:view user.index
Make a view resource
by passing just the name of the resource
, (*11)
php artisan make:view user -r
Make a view with a custom extension, (*12)
php artisan make:view user.index -e twig
Make a view and store it in another directory
Note: -p 1
refers to the value of array key of 1
in your config('view.paths')
setting., (*13)
php artisan make:view user.index -p 1
Combine multiple options to fully-customize the view(s) being created
Note: this will create all resource views in your custom directory, with the twig
extension., (*14)
php artisan make:view user -r -p 1 -e twig
Artisan Make View is open-sourced software licensed under the MIT license., (*15)