yiizh/yii2-cdn

A CDN extension for Yii2.

Installs: 159

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

0.1.1 2016-11-10 08:35 UTC

This package is auto-updated.

Last update: 2024-10-26 13:54:51 UTC


README

Packagist Packagist GitHub tag

A CDN extension for Yii2.

You can make your assets using CDN resources without changing your asset bundle code.

Install

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yiizh/yii2-cdn "*"

or add

"yiizh/yii2-cdn": "*"

to the require section of your composer.json file.

Usage

1. Add a component

Add the following code to you config file @app/config/main.php:

// ...
'components' => [
    'cdn' => [
        'class' => 'yiizh\cdn\CDN',
        'assets' => [
            [
                'class' => 'yii\web\JqueryAsset',
                'js' => [
                    'http://cdn.bootcss.com/jquery/2.2.4/jquery.min.js'
                ]
            ],
            [
                'class' => 'yii\bootstrap\BootstrapAsset',
                'css' => [
                    'http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css'
                ]
            ],
        ]
    ],
]
// ...

2. Add cdn to bootstrap

Add the following code to you config file @app/config/main.php:

// ...
'bootstrap' => ['log', 'cdn'],
// ...