1. Go to this page and download the library: Download corneltek/assetkit 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/ */
corneltek / assetkit example snippets
// load the autoload.php from composer
contains asset manifest and types
$config = new AssetKit\AssetConfig( '../assetkit.yml', array(
'root' => APP_ROOT // the absolute path where you run "assetkit" command.
));
// initialize an asset loader
$loader = new AssetKit\AssetLoader( $config );
// load the
$loader = new AssetKit\AssetLoader($config);
$asset = $loader->register("tests/assets/jquery-ui");
$asset = $loader->load("jquery-ui");
$asset = $loader->load("jquery-ui:stylesheet"); // Asset with stylesheet collections only
$asset = $loader->load("jquery-ui:javascript"); // Asset with javascript collections only
$asset = $loader->load("jquery-ui#darkness"); // Asset with darkness theme stylesheet collections only
use AssetKit\AssetConfig;
// Please install php-fileutil extension for beter performance,
// To use AssetCompiler, AssetLoader or AssetRender, we need to initialize AssetConfig object.
$config = new AssetKit\AssetConfig( 'config/assetkit.yml',array(
// the application root, contains the assetkit.yml file.
'root' => APPLICATION_ROOT,
'cache' => new UniversalCache\ApcCache(array( 'namespace' => 'myapp_' ));
));
$loader = new AssetKit\AssetLoader( $config );
$compiler = new AssetKit\AssetCompiler($config, $loader);
$compiler->enableFstatCheck();
$compiler->defaultJsCompressor = 'uglifyjs';
$compiler->defaultCssCompressor = 'cssmin';
$assets = $loader->loadAssets(array( 'jquery', 'jquery-ui') );
$render = new AssetKit\AssetRender($config,$loader, $compiler);
$render->renderAssets($assets,'page-id');
$loader = new AssetKit\AssetLoader($config);
// load asset from a directory that might contains a manifest file,
// Note: Since you're going to put the assetkit.yml file
// In your VCS, you should use relative path instead of
// absolute path.
$asset = $loader->register("tests/assets/jquery");
// load asset from a manifest file directly,
$asset = $loader->loadManifestFile("tests/assets/jquery/manifest.yml");
// load multiple asset at one time
$assets = $loader->loadAssets(array('jquery','jquery-ui'));
$jquery = $loader->load('jquery');
$jqueryui = $loader->load('jquery-ui');
// get all loaded asset objects
$assets = $loader->all();
// get all loaded asset objects by pairs.
// array( 'name' => [asset object], ... )
$assetMap = $loader->pairs();
// check if we've loaded the asset by asset name
if( $loader->has('jquery') ) {
// do something here.
}
$updater = new ResourceUpdater;
$updater->update($asset);
$installer = new AssetKit\Installer;
$installer->install( $asset );
$installer->uninstall( $asset );
$installer = new AssetKit\LinkInstaller;
$installer->install( $asset );
$installer->uninstall( $asset );