PHP code example of xutl / yii2-qcloud

1. Go to this page and download the library: Download xutl/yii2-qcloud 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/ */

    

xutl / yii2-qcloud example snippets


return [
    //....
    'components' => [
        'api' => [
            'class' => 'xutl\qcloud\ApiGateway',//注意,绑定secretId、secretKey的接口一定要绑定使用计划,并且把使用计划指定给secretId
            'baseUrl' => 'http://service-xxxxxxx.ap-shanghai.apigateway.myqcloud.com/test',
            'secretId' => 'asdfasdfk;lasdf',
            'secretKey' => '123123123',
            //注:使用方式同 YII2 自带的 httpclient 一致,这里只是封装了一下Header
        ],
        'qcloud' => [
            'class' => 'xutl\qcloud\Qcloud',
            'secretId' => 'abcdefg',
            'secretKey' => 'abcdefg',
            'params'=> [//这里是非扩展的配置参数,如队列任务等
                'aaa.appvvvKey' => 123456789
            ],
            'components' => [
               //各子组件配置,如果无需配置不写即可。也可动态注入配置。
               //如果子组件使用独立的 `secretId` 和 `secretKey` 那么在子组件中单独配置即可,如果没有配置默认使用父  `accessId` 和 `accessKey` 。
               //如果你自己扩展了其他的子组件,这里定义下新的组件配置即可,配置方式,数组接口和 YII 原生组件一致!
              //etc
            ]
        ],
    ]
];

$cdn = Yii::$app->qcloud->cdn;
$response = $cdn->describeCdnHosts();
print_r($response->data);