_php instance of methods for creating and deleting application View files based on Artisan view expansion package in Laravel

Source: Internet
Author: User
Tags php programming smarty template

This example describes the method for creating and deleting application View files in Laravel based on the Artisan view expansion package. Share to everyone for your reference, specific as follows:

1. Introduction

This expansion pack adds two view-related artisan commands to the Laravel application so that we can create and manage view files through the artisan command, which is a further liberating of productivity.

2, installation

or through the composer installation:

Composer require Sven/artisan-view

After the installation completes, register the service provider Artisanviewserviceprovider to the providers array in config/app.php:

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

3. Use

If you run PHP now, you will find two more commands for creating and deleting view files, respectively: Artisan

-Make:view
-Scrap:view

Create a View

Create a index.blade.php view file under View root views

$ PHP Artisan Make:view Index

Create a index.blade.php view file under Subdirectories pages

$ php Artisan Make:view Pages.index

Create a view file in a custom directory (relative to the system root)

$ php Artisan Make:view Index--directory=custom/path

Specify the view file name extension

$ php Artisan Make:view Index--extension=html

Inheriting a view that already exists

$ php Artisan Make:view Index--extends=app

Add title and content sections to a view

$ php Artisan Make:view Index--sections=title,content

Create a resource named Products (include index, create, edit, show view)

$ PHP Artisan Make:view Products--resource

Create a specified action resource (index, create, and edit)

$ PHP Artisan Make:view Products--resource--verbs=index,create,edit

Create a resource file that inherits from layout and contains Foo, bar

$ PHP Artisan Make:view products--resource--extends=layout--sections=foo,bar

Delete View

Delete view File index.blade.php

$ PHP Artisan Scrap:view Index

Through. Delete a subdirectory view file

$ php Artisan Scrap:view Pages.index

More interested in laravel related content readers can view the site topics: "Laravel Framework Introduction and Advanced Course", "PHP Excellent Development Framework Summary", "Smarty Template Primer Tutorial", "PHP date and Time usage summary", "PHP object-oriented Program Design Introductory Course ", PHP string (String) Usage summary," PHP+MYSQL Database operation Introduction Tutorial "and" PHP common database Operation Skills Summary "

I hope this article will help you with your PHP programming based on the Laravel framework.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.