• This repository has been archived on 15/Sep/2023
  • Stars
    star
    871
  • Rank 52,385 (Top 2 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

👀 Manage your views in Laravel projects through artisan

artisan-view

Artisan View

Latest Version on Packagist Total Downloads Software License Build Status StyleCI

Warning

This package has been abandoned. The make:view command 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 before v10.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!

Index

Installation

You'll have to follow a couple of simple steps to install this package.

Downloading

Via composer:

composer require sven/artisan-view --dev

Registering the service provider

If 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);
    }    
}

Usage

If you now run php artisan you will see two new commands in the list:

  • make:view
  • scrap:view

Creating views

# 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

Extending and sections

# 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 multiple sections to the view
$ php artisan make:view index --section=title --section=content

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

# Create sections for each @yield statement in the extended view
$ php artisan make:view index --extends=app --with-yields

# Add @push directives for each @stack statement in the extended view
$ php artisan make:view index --extends=app --with-stacks

REST resources

# 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

Scrapping views

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

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

This 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

Scrapping a REST resource

# Remove the resource called 'products'
$ php artisan scrap:view products --resource

This 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=edit

Mix and match

Of 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')

@endsection

Contributing

All contributions (in the form on pull requests, issues and feature-requests) are welcome. See the contributors page for all contributors.

License

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

More Repositories

1

flex-env

🌳 Manage your .env file in Laravel projects through artisan
PHP
102
star
2

env-providers

👷 Load Laravel service providers based on your application's environment.
PHP
77
star
3

forge-cli

🔥 A command line utility to interact with your Laravel Forge servers, sites, and more.
PHP
64
star
4

artisan-shortcuts

🍰 Register shortcuts to execute multiple artisan commands
PHP
57
star
5

file-config

📄 Store and read configuration values using files on disk.
PHP
27
star
6

super-basic-auth

🔒 A lightweight package to add basic authentication to your Laravel app.
PHP
23
star
7

laravel-testing-utils

🔬 Some useful assertions for in your Laravel application
PHP
21
star
8

helpers

😁 A collection of useful helper functions for in Laravel applications.
PHP
20
star
9

laravel-ide

💻 Generate IDE helper files for your Laravel applications with a single command.
PHP
7
star
10

dns-template

Manage your DNS from GitHub with DNSControl
JavaScript
6
star
11

commonmark-image-media-queries

Use media queries for images in your CommonMark-rendered Markdown.
PHP
6
star
12

package-skeleton

📦 My base for PHP packages.
PHP
6
star
13

laravel-view-assertions

🧑‍🔬 The missing assertions for your views in your Laravel applications.
PHP
6
star
14

emote-cli

Emotes from the command line ⊂(◉‿◉)つ
PHP
4
star
15

meeseeks

📺 🙊 I'm mister Meeseeks, look at meeeeeeeeeeeeeeeeeeeeee
HTML
3
star
16

minecraft-php

📦 🎮 A wrapper around Mojang's Minecraft API.
PHP
2
star
17

svenluijten.com-old

🙋‍♂️ The source for my personal website & blog
PHP
2
star
18

setup-php-issue

1
star
19

kennissessie-laravel

Kennissessie Laravel, gegeven bij E-sites
PHP
1
star
20

dotfiles

💻 My macOS dotfiles
Shell
1
star
21

awesome-password-managers

🔒 A curated list of awesome password managers
1
star
22

asdf-kluctl

kluctl plugin for asdf
Shell
1
star
23

laravel-collection-testing-helpers

🧑‍🏫 Convenience methods on your Laravel collections to make testing them more fluent.
PHP
1
star
24

heap

📦 🗻 Easier handling for arrays in PHP.
PHP
1
star