📦 👀 Manage the views in Laravel projects through artisan
PHP
Latest commit 6d44bde Jan 12, 2017 @svenluijten committed on GitHub Update year of copyright in license

README.md

artisan-view

Artisan View

Latest Version on Packagist Total Downloads Software License Build Status Code Climate Code Quality SensioLabs Insight

This package adds a couple of view-related commands to Artisan in your Laravel projects. It is super simple to use and easy to understand for everyone.

Installation

Via composer:

$ composer require sven/artisan-view

Or add the package to your dependencies in composer.json and run composer update to download the package:

{
    "require": {
        "sven/artisan-view": "^1.0"
    }
}

Next, add the ArtisanViewServiceProvider to your providers array in config/app.php:

// config/app.php
'providers' => [
    ...
    Sven\ArtisanView\ArtisanViewServiceProvider::class,
];

If you want to only load this service provider in a specific environment (like local or development), take a look at sven/env-providers.

Usage

If you now run php artisan you can see two new commands:

  • make:view
  • scrap:view

Create a 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 in a custom directory
$ php artisan make:view index --directory=custom/path

# Give the view a custom file extension
$ php artisan make:view index --extension=html

# Extend an existing view
$ php artisan make:view index --extends=app

# Add a section to the view
$ php artisan make:view index --section=content

# Add an inline section to the view
$ php artisan make:view index --section="title:Hello world"
# Remember to add quotes around the section if you want to use spaces

# Add 2 sections to the view
$ php artisan make:view index --sections=title,content

# Add one inline and one block-level section to the view
$ php artisan make:view index --sections="title:Hello world,content"
# Remember to add quotes around the sections if you want to use spaces

# Create a resource called 'products'
$ php artisan make:view products --resource

# Create a resource with only specific verbs
$ php artisan make:view products --resource --verbs=index,create,edit

# Create a resource that extends views and adds sections
$ php artisan make:view products --resource --extends=layout --sections=foo,bar

# Use the force flag to force the creation of the view
$ php artisan make:view index --force
# This will overwrite a view if it already exists

Scrap a view

# Scrap the view 'index.blade.php'
$ php artisan scrap:view index

# Remove the view by dot notation
$ php artisan scrap:view pages.index

Contributing

All contributions (pull requests, issues and feature requests) are welcome. Make sure to read through the CONTRIBUTING.md first, though. See the contributors page for all contributors.

License

sven/artisan-view is licensed under the MIT License (MIT). Please see the license file for more information.