trapvincenzo/static-view-cache
Larablocks Analysis
trapvincenzo/static-view-cache works with Laravel 4 (latest release 1.0, Mar 6, 2015), which reached end of life: no more fixes, even for security.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- Supports only Laravel 4, past end of life
- No release in the last 12 months (last: Mar 6, 2015)
- 0 downloads a month (needs 10,000)
- 1 GitHub star (needs 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: Mar 6, 2015.
- No releases in the last 12 months.
- First released: Mar 6, 2015.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Nov 28, 2026.
| Install | |
|---|---|
composer require trapvincenzo/static-view-cache |
|
| Latest Version: | 1.0 |
| PHP: | >=5.4.0 |
| Laravel: | 4 |
| License: | MIT |
| Last Updated: | Mar 19, 2015 |
| Links: | GitHub · Packagist |
#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!
Alternatives to trapvincenzo/static-view-cache
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.0 | >=5.4.0 | 4.2.* | MIT |