1. Go to this page and download the library: Download odan/plates-asset-cache library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
odan / plates-asset-cache example snippets
use League\Plates\Engine;
use Odan\PlatesAsset\AssetEngine;
use Odan\PlatesAsset\PlatesAssetExtension;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
$engine = new Engine('/path/with/html/templates');
$options = [
// Public assets cache directory
'path' => '/var/www/example.com/htdocs/public/assets/cache',
// Public cache directory permissions (octal)
// You need to prefix mode with a zero (0)
// Use -1 to disable chmod
'path_chmod' => 0750,
// The public url base path
'url_base_path' => 'assets/cache/',
// Internal cache settings
//
// The main cache directory
// Use '' (empty string) to disable the internal cache
'cache_path' => '/var/www/example.com/htdocs/temp',
// Used as the subdirectory of the cache_path directory,
// where cache items will be stored
'cache_name' => 'assets-cache',
// The lifetime (in seconds) for cache items
// With a value 0 causing items to be stored indefinitely
'cache_lifetime' => 0,
// Enable JavaScript and CSS compression
// 1 = on, 0 = off
'minify' => 1
];
// Register asset extension
$engine->loadExtension(new PlatesAssetExtension(new AssetEngine($engine, $options)));
/** @var League\Plates\Template\Template $this */
$engine = new League\Plates\Engine('/path/to/templates');
echo $engine->render('index', ['baseUrl' => '']);