定制 trapvincenzo/static-view-cache 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

trapvincenzo/static-view-cache

最新稳定版本:1.0

Composer 安装命令:

composer require trapvincenzo/static-view-cache

包简介

Static view cache for laravel 4

README 文档

README

#Static View Cache for Laravel4 (Blade template engine)

Suppose to include a view (with dynamic data) inside another view:

<ul>
	@include('cardetail', ['car' => $car])
</ul>

For this statement, the blade engine creates a cached file for the subview like this:

<ul>
	<?php echo $__env->make('car', $car, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>;
</ul>

This means that for every request of the page, the rendering code is executed.

##Loop The problem comes when the inclusion is made inside a loop. Executing the code at every iteration, can cause a big delay in the rendering of the page.

##Cached subview What the StaticViewCache does, is to save a cached version of the generated subview with the real data. Doing so, the code for the rendering will be executed just the first time (to create the cache).

##How to use To install the StaticViewCache as a Composer package, add this line to your composer.json:

"trapvincenzo/static-view-cache": "dev-master"

and update your vendor folder running the composer update command.

Register the service provider (app/config/app.php):

'providers' => array(
	...
	'Trapvincenzo\StaticViewCache\StaticViewCacheServiceProvider'
	...
)

Replace the @include statement with:

StaticViewCache::render($viewName, $id, $data , $path )

string $viewName view name

string $id unique identifier for the view (different for each iteration)

array $data data to use inside the view

[optional] string $path define path inside storage_folder().'/views/' (default 'static')

Enjoy!

统计信息

  • 总下载量: 87
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-16