网站首页 > 开源技术 正文
yii2 cdn,支持 七牛、网易云、腾讯云、阿里云的cdn。需要注意的是,此cdn扩展包只实现了几个常用的api:上传文件 分片上传 检测文件是否存在 删除文件。其他相应的操作需要自行实现。你可以随时使用/取消yii2项目使用cdn。
虽然不是全部实现,但是我们可以学学它的思路,提高我们的见识。
安装
1、使用composer composer的安装以及国内镜像设置请点击此处
$ cd /path/to/yii2-app
$ composer require "feehi/yii2-cdn"
$ composer install -vvv
2、手动导入 下载yii2-cdn包后放置在任意目录 然后在yii2 index.php中
require "/path/to/yii2-cdn/autoload.php";
配置
yii2 cdn是作为一个组件提供服务的,所以得配置yii2 cdn组件。打开common/config/main.php在components块内增加
1.使用七牛的配置
'components' => [
'cdn' => [
'class' => feehi\cdn\QiniuTarget::className(),
'accessKey' => 'xxxxxxx',
'secretKey' => 'xxxxxxxxx',
'bucket' => 'xxx',
'host' => 'http://xxxx.xxx.com'
]
]
2.使用阿里云的配置
'components' => [
'cdn' => [
'class' => feehi\cdn\AliossTarget::className(),
'bucket' => 'xxx',
'accessKey' => 'xxxx',
'accessSecret' => 'xxxxxxx',
'endPoint' => 'oss-cn-beijing.aliyuncs.com',
'host' => 'http://xxxx.xxx.com'
]
]
3.使用腾讯云的配置
'components' => [
'cdn' => [
'class' => feehi\cdn\QcloudTarget::className(),
'appId' => 'xxxxx',
'secretId' => 'xxxxxx',
'secretKey' => 'xxxxxxx',
'region' => 'tj',
'bucket' => 'xxx',
'host' => 'http://image-1251086492.costj.myqcloud.com',
]
]
4.使用网易云的配置
'components' => [
'cdn' => [
class' => feehi\cdn\NeteaseTarget::className(),
'accessKey' => 'xxxxx',
'accessSecret' => 'xxxxxxx',
'endPoint' => 'nos-eastchina1.126.net',
'bucket' => 'xxx',
'host' => 'http://xxxx.xxx.com'
]
]
5.不使用cdn时的配置(不需要修改代码文件)
'components' => [
'cdn' => [
class' => feehi\cdn\DummyTarget::className(),
]
]
yii2-cdn包地址
主页地球回复 PHPER6318 或关注、私信 获取。
猜你喜欢
- 2024-09-11 少年歌行。第2部。萧崇登基后……
- 2024-09-11 少年歌行2:司空千落怀孕,萧瑟居然要娶别人为妻
- 2024-09-11 YII框架学习(新手)NO.2(yii框架设计模式)
- 2024-09-11 yii安装与使用详解(easy_install安装)
- 2024-09-11 小编教你 YII2框架模块如何绑定二级域名
- 2024-09-11 一款基于Yii2+Vue2.0+uniapp的开源商城
- 2024-09-11 Yii2开发中js冲突 如何禁用自带的 yii、jquery 和 bootstrap
- 2024-09-11 一款基于Yii2开发的免费商城系统(开发一款游戏的步骤)
- 2024-09-11 Yii2连接pgsql,设置默认schema(sqlplus默认连库)
- 2024-09-11 php生命周期、Laravel生命周期、Yii2生命周期、ThinkPHP生命周期
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- jdk (81)
- putty (66)
- rufus (78)
- 内网穿透 (89)
- okhttp (70)
- powertoys (74)
- windowsterminal (81)
- netcat (65)
- ghostscript (65)
- veracrypt (65)
- asp.netcore (70)
- wrk (67)
- aspose.words (80)
- itk (80)
- ajaxfileupload.js (66)
- sqlhelper (67)
- express.js (67)
- phpmailer (67)
- xjar (70)
- redisclient (78)
- wakeonlan (66)
- tinygo (85)
- startbbs (72)
- webftp (82)
- vsvim (79)
本文暂时没有评论,来添加一个吧(●'◡'●)