yiizh / yii2-cdn
Yii2 的 CDN 扩展。
0.1.1
2016-11-10 08:35 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: ~2.0.3
This package is auto-updated.
Last update: 2024-09-26 13:37:56 UTC
README
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'], // ...