yiizh/yii2-cdn

Yii2 的 CDN 扩展。

安装: 159

依赖项: 0

建议者: 0

安全: 0

星标: 2

关注者: 2

分支: 1

开放问题: 0

类型:yii2-extension

0.1.1 2016-11-10 08:35 UTC

This package is auto-updated.

Last update: 2024-09-26 13:37:56 UTC


README

Packagist Packagist GitHub tag

Yii2 的 CDN 扩展。

您可以在不更改资产包代码的情况下,使用 CDN 资源创建您的资产。

安装

安装此扩展的首选方式是通过 composer

运行以下命令之一

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

"yiizh/yii2-cdn": "*"

将以下内容添加到您的 composer.json 文件的 require 部分。

使用方法

1. 添加组件

将以下代码添加到您的配置文件 @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. 将 cdn 添加到引导

将以下代码添加到您的配置文件 @app/config/main.php

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