1. Go to this page and download the library: Download tekton/assets 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/ */
tekton / assets example snippets
use Tekton\Assets\AssetManager;
$manager = new AssetManager(__DIR__, 'http://localhost:8000/');
// Get file path and URL
$path = $manager->get('images/logo.png')->path();
$url = $manager->get('images/logo.png')->url();
use Tekton\Assets\AssetManager;
$manager->queue('scripts')->add('jquery', 'js/jquery.min.js');
$manager->queue('scripts')->add('app', 'js/app.js', ['jquery']);
// Output every script
foreach ($manager->queue('scripts')->all() as $asset) {
echo '<script src="'.$asset->url().'"></script>';
}
use Tekton\Assets\AssetManifest;
$manager->setManifest(new AssetManifest('manifest.json', 'cache/'));
use Tekton\Assets\AssetCompiler;
use Tekton\Assets\Filters\MinifyFilter;
$compiler = new AssetCompiler('cache/', 'http://localhost:8000/cache/');
$compiler->registerFilter('minify', new MinifyFilter);
$manager->setCompiler($compiler);
// Compile single file
echo '<link href="'.$manager->get('css/main.css')->compile('minify')->url().'">';
// Compile queue
$manager->queue('styles')->add('one', 'css/one.css');
$manager->queue('styles')->add('two', 'css/two.css', ['one']);
foreach ($manager->queue('styles')->compile('minify') as $asset) {
echo '<link href="'.$asset->url().'">';
}
// OR combine queue into single file
echo '<link href="'.$manager->queue('styles')->compile('minify', true)->url().'">';
use Tekton\Assets\Filters\ScssFilter;
$compiler->registerFilter('scss', new ScssFilter);
// Compile SCSS and test all SCSS files for changes
echo '<link href="'.$manager->get('scss/main.scss')->compile(['scss', 'minify'], glob('scss/*.scss'))->url().'">';
// For queues the additional paths to test are the third argument
$manager->queue('styles')->add('vendor', 'css/vendor.css');
$manager->queue('styles')->add('app', 'scss/main.scss', ['vendor']);
foreach ($manager->queue('styles')->compile('scss', false, glob('scss/*.scss')) as $asset) {
echo '<link href="'.$asset->url().'">';
}
$compiler->setIgnoreCacheTime(true);
// After deployment...
$compiler->clearCache();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.