2017 © Pedro Peláez
 

library static-view-cache

Static view cache for laravel 4

image

trapvincenzo/static-view-cache

Static view cache for laravel 4

  • Thursday, March 19, 2015
  • by trapvincenzo
  • Repository
  • 1 Watchers
  • 1 Stars
  • 78 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Static View Cache for Laravel4 (Blade template engine)

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

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

For this statement, the blade engine creates a cached file for the subview like this:, (*2)

<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., (*3)

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., (*4)

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)., (*5)

How to use

To install the StaticViewCache as a Composer package, add this line to your composer.json:, (*6)

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

and update your vendor folder running the composer update command., (*7)

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

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

Replace the @include statement with:, (*9)

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

string $viewName view name, (*10)

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

array $data data to use inside the view, (*12)

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

Enjoy!, (*14)

The Versions

19/03 2015

dev-master

9999999-dev

Static view cache for laravel 4

  Sources   Download

MIT

The Requires

 

by Vincenzo Trapani

laravel cache laravel4 view

06/03 2015

1.0

1.0.0.0

Static view cache for laravel 4

  Sources   Download

MIT

The Requires

 

by Vincenzo Trapani

laravel cache laravel4 view