PHPackages                             silentlun/yii2-cdn - 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. silentlun/yii2-cdn

ActiveYii2-extension

silentlun/yii2-cdn
==================

CDN extension for YII2

1.0(4y ago)014BSD-3-ClausePHP

Since Oct 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/silentlun/yii2-cdn)[ Packagist](https://packagist.org/packages/silentlun/yii2-cdn)[ RSS](/packages/silentlun-yii2-cdn/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

yii2-cdn
========

[](#yii2-cdn)

yii2 上传文件扩展，目前仅支持本地和七牛云，其他云存储待补充。

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

[](#installation)

安装此扩展的首选方法是通过 [composer](http://getcomposer.org/download/).

Either run

```
php composer require --prefer-dist silentlun/yii2-cdn "*"

```

or add

```
"silentlun/yii2-cdn": "*"

```

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

使用方法
----

[](#使用方法)

### 1.配置组件 :

[](#1配置组件--)

安装扩展后，打开common/config/main.php在components块内增加 :

1.使用本地存储的配置

```
	'components' => [
	    'cdn' => [
	        'class' => 'silentlun\cdn\LocalTarget',
	        'domain' => '本地cdn域名',
	    ]
	]
```

2.使用七牛云的配置

```
	'components' => [
	    'cdn' => [
	        'class' => 'silentlun\cdn\QiniuTarget',
			'accessKey' => '七牛key',
			'secretKey' => '七牛secret',
			'bucket' => '七牛bucket',
			'domain' => '七牛cdn域名',
	    ]
	]
```

### 2.控制器中使用

[](#2控制器中使用)

```
	$localFile = '本地路径';
	$destFile = '上传路径';
	$cdn = Yii::$app->cdn;
	$cdn->upload($localFile, $destFile);
	$imgUrl = $cdn->getCdnUrl($destFile);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1676d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/77e448a626a78a92eee5ccb5303bbbcaae55f00e4414f769f295b4f7f72b05ad?d=identicon)[silentlun](/maintainers/silentlun)

---

Top Contributors

[![silentlun](https://avatars.githubusercontent.com/u/16114449?v=4)](https://github.com/silentlun "silentlun (1 commits)")

---

Tags

yii2cdn

### Embed Badge

![Health badge](/badges/silentlun-yii2-cdn/health.svg)

```
[![Health](https://phpackages.com/badges/silentlun-yii2-cdn/health.svg)](https://phpackages.com/packages/silentlun-yii2-cdn)
```

###  Alternatives

[blacksmoke26/yii2cdn

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

1412.0k](/packages/blacksmoke26-yii2cdn)

PHPackages © 2026

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