Git Product home page Git Product logo

yii2-cdn's Introduction

yii2 cdn

yii2 cdn,支持 七牛、网易云、腾讯云、阿里云的cdn。可以随时使用/取消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(),
        ]
    ]

示例

examples/demo.php

说明

yii2 cdn集成了国内常用四个cdn厂商的sdk,以yii2组件的方式提供服务,屏蔽了厂商不同的api名称、调用方式。但是yii2 cdn只实现了几个常用的api:上传文件 分片上传 检测文件是否存在 删除文件。其他相应的操作需要自行实现。

yii2-cdn's People

Contributors

liufee avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.