sven/artisan-view
最新稳定版本:v3.6.1
Composer 安装命令:
composer require sven/artisan-view
包简介
Manage your views in Laravel projects through artisan
README 文档
README
Artisan View
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:viewscrap: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.
sven/artisan-view 适用场景与选型建议
sven/artisan-view 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 762.01k 次下载、GitHub Stars 达 868, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「templates」 「laravel」 「views」 「artisan」 「blade」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sven/artisan-view 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sven/artisan-view 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sven/artisan-view 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
CakePHP 4.x AdminLTE Theme.
The tenancy/tenancy views mutations
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
The "View Counter" bundle
CakePHP 3.x Gentelella Theme.
统计信息
- 总下载量: 762.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 882
- 点击次数: 20
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 未知
