Manage your views in Laravel projects through artisan
Manage your views in Laravel projects through artisan
[!WARNING] This package has been abandoned. The
make:viewcommand is a part of Laravel since v10.23.0, you should use that instead. You will still be able to install this package when using Laravel versions beforev10.23.0.
This package adds a handful of view-related commands to Artisan in your Laravel project. Generate blade files that extend other views, scaffold out sections to add to those templates, and more. All from the command line we know and love!
You'll have to follow a couple of simple steps to install this package.
Via composer:
composer require sven/artisan-view --devIf you're using Laravel 5.5 or above, you can skip this step. The service provider will have already been registered thanks to auto-discovery.
Otherwise, register Sven\ArtisanView\ServiceProvider::class manually in your AppServiceProvider's
register method:
public function register()
{
if ($this->app->environment() !== 'production') {
$this->app->register(\Sven\ArtisanView\ServiceProvider::class);
}
}If you now run php artisan you will see two new commands in the list:
make:viewscrap:view# Create a view 'index.blade.php' in the default directory
$ php artisan make:view index
# Create a view 'index.blade.php' in a subdirectory ('pages')
$ php artisan make:view pages.index
# Create a view with a different file extension ('index.html')
$ php artisan make:view index --extension=html…# Create a resource called 'products'
$ php artisan make:view products --resource
# Create a resource with only specific verbs
$ php artisan make:view products --resource --verb=index --verb=create --verb=edit# Remove the view 'index.blade.php'
$ php artisan scrap:view index
# Remove the view by dot notation
$ php artisan scrap:view pages.indexThis will ask you if you're sure. To skip this question, pass the --force flag:
# Don't ask for confirmation
$ php artisan scrap:view index --force# Remove the resource called 'products'
$ php artisan scrap:view products --resourceThis will remove the views products.index, products.show, products.create, and products.edit. If the directory
products/ is empty after doing that, it will also be deleted.
You can scrap part of a resource by adding --verb flags:
# Remove the 'products.create' and 'products.edit' views.
$ php artisan scrap:view products --resource --verb=create --verb=editOf course, all the options work well together like you'd expect. So the following command...
$ php artisan make:view products --resource --extends=app --section="title:This is my title" --section=content... will put the following contents in products/index.blade.php, products/edit.blade.php, products/create.blade.php,
and products/show.blade.php:
@extends('app')
@section('title', 'This is my title')
@section('content')
@endsectionAll contributions (in the form on pull requests, issues and feature-requests) are welcome. See the contributors page for all contributors.
sven/artisan-view is licenced under the MIT License (MIT). Please see the
license file for more information.
No open issues yet, or sync has not completed.