PHP code example of fgh151 / core-assets

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

    

fgh151 / core-assets example snippets


'components' => [
    'clientScript' => [
        'class' => 'fgh151\core\assets\ClientScript',
    ]
]


/**
 * @author : Fedor B Gorsky
 */

namespace app\assets\site;

use fgh151\core\assets\Asset;
use fgh151\core\assets\BootstrapAsset;
use fgh151\core\assets\FontAwesomeAsset;

class SiteAsset extends Asset
{
    //Подключаем стили
    public static $css = [
        __DIR__ . '/css/main.css',
    ];
    //Подключаем стили с внешних ресурсов
    public static $externalCss = [
        'https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,800',
    ];
    //Подключаем скрипты с внешних ресурсов
    public static $externalJs = [
        '//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js'
    ];
    //Подключаем скрипты
    public static $js = [
        __DIR__ . '/js/script.js',
    ];
    //Указываем зависимости
    public static $depends = [
        BootstrapAsset::class,
        FontAwesomeAsset::class
    ];
}

use app\assets\site\SiteAsset;

Yii::$app->clientScript->register(SiteAsset::class);

use app\assets\site\SiteAsset;

Yii::app()->clientScript->register(SiteAsset::class);