blacksmoke26/yii2cdn 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

blacksmoke26/yii2cdn

Composer 安装命令:

composer require blacksmoke26/yii2cdn

包简介

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License GitHub issues GitHub forks GitHub stars Docs Twitter

yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

Production Ready: Used in several real projects is enough to prove its stability.

Minimum requirements: PHP 7.0+ / Yii2 Framework 2.0.12+

Bugs / Feature Request?: Create your issue here.

Resources

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist blacksmoke26/yii2cdn "*"

or add

"blacksmoke26/yii2cdn": "*"

to the require section of your composer.json file.

Usage

Info: This tutorial will demonstrate how to use FancyBox3 library in a production (online/CDN) or development (local/offline) environment.

I. Installing a library

  1. Create a cdn directory under the /root/web folder.
  2. Install or download FancyBox3 library under cdn directory.

II. Add a component

  1. Open @app/config/main.php in your code editor.
  2. Add a new property cdn under components section like the following code:
// ...
'components' => [
  // ...
  'cdn' => [
    'class' => '\yii2cdn\Cdn',
      'baseUrl' => '/cdn',
      'basePath' => dirname(__DIR__) . '/web/cdn',
      'components' => [
      'jquery-fancybox' => [
        'css' => [
          '@attributes' => [
            'noNameInPathUrls' => true, // Hide /css in urls
          ],
          [
            'dist/jquery.fancybox.css', // offline version
            '@cdn' => '//cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.css', // online version
          ],
        ],
        'js' => [
          '@attributes' => [
            'noNameInPathUrls' => true, // Hide /js in urls
          ],
          [
            'dist/jquery.fancybox.js', // offline version
            '@cdn' => '//cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.js', // online version
          ],
        ],
      ],
    ],
  ],
  // ...
],
// ...

III. Registering assets

  1. Open any view file and paste the following line:
//...
Yii::$app->cdn->get('jquery-fancybox')->register();
//...

IV. Final moment

  1. Browse the action url in your browser and check the view souce.

Now it's time to play around, See ya!

统计信息

  • 总下载量: 12.38k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2016-04-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固