PHP code example of laradic / assets

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

    

laradic / assets example snippets


$asset = Asset::create('script', 'global/plugins/jquery.min.js');

$compiled = Asset::compile('script', 'global/plugins/jquery.min.js');
echo $compiled->getUrl();   # full url to the compiled asset
echo $compiled->getHtml();  # script/link html tag
echo $compiled->getUri();   # uri to the compiled asset
echo $compiled->getPath();  # absolute file path to the compiled asset

$area = Asset::area('area/package');
$group = $area->group('global');
$group->add('bootstrap', 'css/bootstrap.css');
$group->add('font-awesome', 'global/plugins/font-awesome/css/font-awesome.min.css', 'bootstrap');

Asset::area('area/package')
     ->group('global')
     ->add('bootstrap', 'css/bootstrap.css')
     ->add('font-awesome', 'global/plugins/font-awesome/css/font-awesome.min.css', 'bootstrap');

// At a later point, you can continue adding
Asset::area('area/package')
     ->group('global')
     ->add('simple-line-icons', 'global/plugins/simple-line-icons/simple-line-icons.min.css', 'bootstrap')
     ->add('uniform', 'global/plugins/uniform/css/uniform.default.css', 'bootstrap');

Asset::area('area/package')
     ->group('global')
     ->compile('script', $combine = true)
     ->getHtml();

// Query
Asset::query
// Compiles the scripts in group
Asset::compile('script', 'area/package::global', $combine = true)->getHtml();