PHP code example of silentlun / yii2-cdn

1. Go to this page and download the library: Download silentlun/yii2-cdn library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

silentlun / yii2-cdn example snippets


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

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

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

php composer