PHP code example of h4kuna / assets

1. Go to this page and download the library: Download h4kuna/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/ */

    

h4kuna / assets example snippets


/* @var $assets \h4kuna\Assets\Assets */
$assets->addJs('ext/nette2.4.js', ['async' => TRUE]);
echo (string) $assets->renderJs();

class CacheBuilder implements \h4kuna\Assets\DI\ICacheBuilder
{
	public function create(\h4kuna\Assets\CacheAssets $cache, $wwwDir)
	{
		$finder = Nette\Utils\Finder::findFiles('*')->in($wwwDir . '/config');
		foreach ($finder as $file) {
			/* @var $file \SplFileInfo */
			$cache->load(self::replaceSlashOnWindows($file));
		}
	}


	private static function replaceSlashOnWindows(SplFileInfo $file)
	{
		static $isWindows;
		if ($isWindows === NULL) {
			$isWindows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
		}

		if ($isWindows) {
			return str_replace('\\', '/', $file->getPathname());
		}
		return $file->getPathname();
	}
}