johnturingan/laravel-fly-view
Composer 安装命令:
composer create-project johnturingan/laravel-fly-view
包简介
Render Blade templates from string mark-up.
README 文档
README
Is an Extension of Laravel View Class which compiles String Template on the fly. It automatically detects changes on your string template and recompiles it if needed.
This is useful if you want to render your template which came from other sources like CMS or third party API
Since its an Extension of laravel View class. It will not interfere on the usual flow of your application. You can still use laravel view as per normal but with the capability of passing string template.
It supports all directives of Blade Template.
Supports Laravel 5.2+
Installation 🚥
Add the package to your composer.json
"require": {
...
"johnturingan/laravel-fly-view": "{version}"
},
Or just run composer require
$ composer require johnturingan/laravel-fly-view
In config/app.php replace
Illuminate\View\ViewServiceProvider::class
with
Snp\FlyView\Providers\ViewServiceProvider::class
Usage ✅
View normal usage:
Pass path to blade file using dot notation on the first parameter
return view('path.to.view', []);
Flyview usage:
Pass array of strings on the first parameter
return view([ 'String Template with {{$blade}} syntax and @directives' ], []);
or you can do
return view([
'{{ $token }}',
'{{ $me }}'
], [
'token' => Str::uuid(),
'me' => 'Laravel Fly View'
]);
Flyview will merge all strings inside the array before compile. Useful if you have multiple template sources.
You can also use if from response helper like this.
return response()->view([
'{{ $token }}',
'{{ $me }}'
], [
'token' => Str::uuid(),
'me' => 'Laravel Fly View on Response Helper'
]);
Like I said before, it will not interfere the usual flow of Laravel View. Meaning you can do something like this.
$bag = [
'include' => [
'{{ $token }} - This is FlyView Include',
'@include("includes.nativeInclude") <br/> Above is Include Inception'
],
'data' => [ 'token' => Str::uuid() ]
];
return view('includeTest', $bag);
Inside your includeTest.blade.php file is this:
@include('includes.nativeInclude', $data)
@include($include, $data)
Including string template to blade template file is possible.
Config 📄
All configuration is same as the default view config in your config folder with an additional settings to minimize view contents. Default is false.
/*
|--------------------------------------------------------------------------
| Minify View Content
|--------------------------------------------------------------------------
|
| This option determines whether or not you want to minify view contents.
| It removes unnecessary whitespace
|
*/
'minify' => false
NOTE:
If you find any bugs or you have some ideas in mind that would make this better. Please don't hesitate to send comment on github.
If you find this package helpful, a simple star is very much appreciated.
MIT LICENSE
copyright © 2018 Scripts and Pixels.
johnturingan/laravel-fly-view 适用场景与选型建议
johnturingan/laravel-fly-view 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.88k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2018 年 02 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「template」 「view」 「laravel」 「blade」 「lumen」 「view caching」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 johnturingan/laravel-fly-view 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 johnturingan/laravel-fly-view 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 johnturingan/laravel-fly-view 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Illuminate View for Morningmedley.
Blade template for Kirby
Simple ASCII output of array data
View5 is a version of Blade Templates for the Mvc5 Framework
E2E Studios PHP Framework adaptation of leafsphp/blade package
统计信息
- 总下载量: 3.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-15