mvccore / ext-view-helper-assets
MvcCore - Extension - View - Helper - Assets - to group, render, minify and cache javascript and css files, to prepare all application assets for final application packing.
v5.3.0
2024-11-21 15:49 UTC
Requires
- php: >=5.4.0
- mvccore/ext-view-helper: ^5.3
- mvccore/mvccore: ^5.3
- tedivm/jshrink: ^1.4
- tubalmartin/cssmin: ^4.1
Requires (Dev)
- nette/tester: <=2.4
- phpstan/phpstan: ^1.10
- tomflidr/tracy: ^2.7.4
This package is auto-updated.
Last update: 2024-11-21 16:01:08 UTC
README
MvcCore View Helper extensin to group, render, minify and cache javascript and css files, to prepare all application assets for final application packing.
Installation
composer require mvccore/ext-view-helper-assets
Features
- grouping files together to deliver them in one response
- optional rendering PHP code inside group files
- optional completing assets url adresses targeting into index.php
packed result, where small data sources (icons, image maps...),
shoud be packed into, if you want to develop and build single
file application.
- Example:
<?php echo $this->AssetUrl('favicon.ico'); ?>
- Example:
- saving grouped files in application temp directory
'/Var/Tmp'
- checking changed sources by file modification time or by file md5 imprint
- no source files checking in application compiled mode (packed into PHP package)
- optional CSS or JS minification by external library
mrclay/minify ^2.2.0
- optional downloading external js files into result group
Example
Base controller code:
namespace App\Controllers; class Base { public function PreDispatch () { parent::PreDispatch(); \MvcCore\Ext\Views\Helpers\Assets::SetGlobalOptions([ cssMinify => TRUE, cssJoin => TRUE, ]); $this->Css('head') ->AppendRendered('/app/root/rel/path/to/first.css') ->Append('/app/root/rel/path/to/second.css'); } }
Layout template code:
<html> <head> <!-- only one file will be generated and delivered: <link rel="stylesheet" href="/Var/Tmp/temp-file-name.css" /> --> <?php echo $this->Css('head')->Render(); ?> </head> <body>...</body> </html>