blacksmoke26/yii2cdn
Composer 安装命令:
composer require blacksmoke26/yii2cdn
包简介
A Yii Framework 2 component for using assets in different environments (Local/CDNs)
关键字:
README 文档
README
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
- Wiki: https://github.com/blacksmoke26/yii2cdn/wiki
- Class Reference: http://blacksmoke26.github.io/yii2cdn/api/
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
- Create a
cdndirectory under the/root/webfolder. - Install or download
FancyBox3library undercdndirectory.
- Path should be
/root/web/cdn/jquery-fancybox. - CDN URLs: https://cdnjs.com/libraries/fancybox/3.3.5
II. Add a component
- Open
@app/config/main.phpin your code editor. - Add a new property
cdnundercomponentssection 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
- Open any view file and paste the following line:
//... Yii::$app->cdn->get('jquery-fancybox')->register(); //...
IV. Final moment
- Browse the action url in your browser and check the view souce.
Now it's time to play around, See ya!
blacksmoke26/yii2cdn 适用场景与选型建议
blacksmoke26/yii2cdn 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.38k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2016 年 04 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「assets」 「extension」 「cdn」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 blacksmoke26/yii2cdn 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 blacksmoke26/yii2cdn 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 blacksmoke26/yii2cdn 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Asset Management for PHP
Caching and compression for Twig assets (JavaScript and CSS).
A custom URL rule class for Yii 2 which allows to create translated URL rules
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
统计信息
- 总下载量: 12.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2016-04-07