PHPackages                             blacksmoke26/yii2cdn - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. blacksmoke26/yii2cdn

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

blacksmoke26/yii2cdn
====================

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

1.0.1(5y ago)1412.0k↓38.1%2[1 issues](https://github.com/blacksmoke26/yii2cdn/issues)Apache-2.0PHPPHP ^8.0

Since Apr 9Pushed 5y ago3 watchersCompare

[ Source](https://github.com/blacksmoke26/yii2cdn)[ Packagist](https://packagist.org/packages/blacksmoke26/yii2cdn)[ Docs](https://github.com/blacksmoke26/yii2cdn)[ RSS](/packages/blacksmoke26-yii2cdn/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (12)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/77ddd5d7caee94c3a152fdd775da66521bad2f7e7cd2272ee11850c24f27d805/68747470733a2f2f706f7365722e707567782e6f72672f626c61636b736d6f6b6532362f7969693263646e2f762f737461626c65)](https://packagist.org/packages/blacksmoke26/yii2cdn) [![Total Downloads](https://camo.githubusercontent.com/36524680c4f17b0ea38b408f5fe0522a69652bdc4ee705128bfa76aa0e23f2ab/68747470733a2f2f706f7365722e707567782e6f72672f626c61636b736d6f6b6532362f7969693263646e2f646f776e6c6f616473)](https://packagist.org/packages/blacksmoke26/yii2cdn) [![Latest Unstable Version](https://camo.githubusercontent.com/b9d777b6a4fc4d08a458463e0ff9edee85e559cdc76e7ba8264c0f759156cfa3/68747470733a2f2f706f7365722e707567782e6f72672f626c61636b736d6f6b6532362f7969693263646e2f762f756e737461626c65)](https://packagist.org/packages/blacksmoke26/yii2cdn) [![License](https://camo.githubusercontent.com/c7518f337432ab6450614a69ed0cf007a4246ae416565e9bed6fb386ae81c6a1/68747470733a2f2f706f7365722e707567782e6f72672f626c61636b736d6f6b6532362f7969693263646e2f6c6963656e7365)](https://packagist.org/packages/blacksmoke26/yii2cdn)[![GitHub issues](https://camo.githubusercontent.com/d89a70a43eaad11d79cc538b646975cd85fa3974f9c4e6fb8245c36d833ae0a0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f626c61636b736d6f6b6532362f7969693263646e2e737667)](https://github.com/blacksmoke26/yii2cdn/issues)[![GitHub forks](https://camo.githubusercontent.com/0b508185324330c823d3d9093a0c03967ebef74254dcb16ed0eb63c162f1b673/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f626c61636b736d6f6b6532362f7969693263646e2e737667)](https://github.com/blacksmoke26/yii2cdn/network)[![GitHub stars](https://camo.githubusercontent.com/546be9472da82708cbf8d4ea7f290041a46d2d91077c3d65ab66552d4827967d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f626c61636b736d6f6b6532362f7969693263646e2e737667)](https://github.com/blacksmoke26/yii2cdn/stargazers)[![Docs](https://camo.githubusercontent.com/ddce24df9bae84bea93df7816ae745a2e321ff37543d86791a5c25e101a174d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d31352532352d79656c6c6f772e737667)](https://github.com/blacksmoke26/yii2cdn/wiki)[![Twitter](https://camo.githubusercontent.com/a0891f3f6ad175ce92e0f4133853497f524bf3ed68507fd54f0dd68db37fea4c/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c2f68747470732f6769746875622e636f6d2f626c61636b736d6f6b6532362f7969693263646e2e7376673f7374796c653d736f6369616c)](https://twitter.com/intent/tweet?text=Yii2cdn+extension:&url=https://github.com/blacksmoke26/yii2cdn)

yii2cdn
=======

[](#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](https://github.com/blacksmoke26/yii2cdn/issues).

Resources
---------

[](#resources)

- **Wiki**:
- **Class Reference**:

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

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

```

or add

```
"blacksmoke26/yii2cdn": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

**Info:** *This tutorial will demonstrate how to use [`FancyBox3`](http://fancyapps.com/fancybox/3/) library in a `production` (online/CDN) or `development` (local/offline) environment.*

#### I. Installing a library

[](#i-installing-a-library)

---

1. Create a `cdn` directory under the `/root/web` folder.
2. Install or download [`FancyBox3`](http://fancyapps.com/fancybox/3/) library under `cdn` directory.

- Path should be `/root/web/cdn/jquery-fancybox`.
- CDN URLs:

#### II. Add a component

[](#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

[](#iii-registering-assets)

---

1. Open any view file and paste the following line:

```
//...
Yii::$app->cdn->get('jquery-fancybox')->register();
//...
```

#### IV. Final moment

[](#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!

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~170 days

Recently: every ~391 days

Total

11

Last Release

1990d ago

Major Versions

0.2.4 → 1.0.02018-07-22

PHP version history (6 changes)0.1.0PHP &gt;=5.4.0

0.1.1PHP ~5.4.0

0.1.4PHP ^5.4.0 || ^7.0

0.2.4PHP ^5.6.0 || ^7.0

1.0.0PHP ^7.0

1.0.1PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/939bcd9f33d3d1cedb2ba689a74d1f21e1330415c41b8d92bc07834b987733e6?d=identicon)[junaidatari](/maintainers/junaidatari)

---

Top Contributors

[![blacksmoke26](https://avatars.githubusercontent.com/u/425744?v=4)](https://github.com/blacksmoke26 "blacksmoke26 (104 commits)")

---

Tags

assetscdncomponentsmanagementphpyii2yii2extensionassetscdn

### Embed Badge

![Health badge](/badges/blacksmoke26-yii2cdn/health.svg)

```
[![Health](https://phpackages.com/badges/blacksmoke26-yii2cdn/health.svg)](https://phpackages.com/packages/blacksmoke26-yii2cdn)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
