2017 © Pedro Peláez
 

yii2-extension aliyun

Yii2 extension for Aliyun library

image

gulltour/aliyun

Yii2 extension for Aliyun library

  • Friday, April 21, 2017
  • by weijiansdlx
  • Repository
  • 1 Watchers
  • 8 Stars
  • 96 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 6 Versions
  • 2 % Grown

The README.md

阿里云[OSS,DAYU,LOG,MNS, MQ]

阿里云官方SDK的Composer封装,支持Yii2。 添加删除文件的功能,修改getUrl(只返回文件外链url,不带其他参数)。, (*1)

安装

$ php composer.phar require gulltour/aliyun "~1.0.0", (*2)

OSS Yii2使用

修改config/params.php, (*3)

添加:, (*4)

'oss'=>[
         'class'=>'gulltour\aliyun\oss\AliyunOss',
         'bucket'=>'',
         'AccessKeyId' => '',
         'AccessKeySecret' => '',
         'ossServer' => '', //服务器外网地址,杭州为 http://oss-cn-hangzhou.aliyuncs.com
         'ossServerInternal' => '', //服务器内网地址,杭州为 http://oss-cn-hangzhou-internal.aliyuncs.com 如果为空则不走内网上传,内网上传会节省流量
         'imageHost' => '' //自定义资源域名 默认为 http://bucket.img-cn-hangzhou.aliyuncs.com/
     ],

使用


Yii::$app->oss->upload2oss($filePath, $ssoPath); Yii::$app->oss->getImageUrl($path, $style=null);

LOG Yii2配置

 'log'=>[
          'class'=>'aliyun\oss\AliyunLog',
          'logstore'=>'gulltour',
          'project'=>'',
          'AccessKeyId' => '',
          'AccessKeySecret' => '',
          'endpoint'=>'oss-cn-hangzhou.aliyuncs.com',
       ],

阿里大于 Yii2配置

 'dayu'=>[
             'class'=>'gulltour\aliyun\aliyunDayu',
             'appKey' => '',
             'secretKey' => '',
             'signName' => '',
         ],

使用


Yii::$app->dayu->smsSend($mobile, $params, $template);

MQ Yii2使用

配置

在组件配置中添加如下配置,, (*5)

'notificationMq' => [
            'class' => 'gulltour\aliyun\AliyunMQ',
            'endpoint' => 'http://publictest-rest.ons.aliyun.com',
            'topic' => 'kooeu_email_sms',
            'accessKeyId' => 'iEjugjCFUSBh1IXu',
            'accessKeySecret' => 'kvNO5lvWEBLGAEOJKfTWFjVJmWmMde',
            'producerGroup' => 'PID_HYW_Message',
            'consumerGroup' => 'CID_HYW_Message',
            'messageReceiver' => function($message) {echo $message;},
            'sentCallback' => function($message, $aliMsgID) {echo $message;echo $aliMsgID;},
]

使用示例

Yii::$app->notificationMq->sendMessage('1234567891');

MNS Yii2使用

YII2插件-阿里云消息队列SDK

配置

'mns'=>[
    'class'=>'gulltour\aliyun\aliyunMns',
    'accessId' => '',
    'accessKey' => '',
    'endpoint' => 'http://.mns.cn-beijing.aliyuncs.com/',
],

使用示例:

// 发送消息到队列
\Yii::$app->mns->sendMessage("QueueName", "content demo");
// 接收队列消息
$messageObject = \Yii::$app->mns->receiveMessage("QueueName");
$data = $messageObject->getMessageBody();
// 删除队列消息
\Yii::$app->mns->->deleteMessage('QueueName', $messageObject);
//publish 消息到主题
\Yii::$app->mns->publishMessage('TopicName', $data);
//订阅主题,在Yii2的 controller 中接收推送过来的数据
public function actionSubscribe()
{
    $message = \Yii::$app->request->getRawBody();
    $data = json_decode($message, true); //如果消息是JSON,PHP中需要转换成数组
}

License

除 “版权所有(C)阿里云计算有限公司” 的代码文件外,遵循 MIT license 开源。, (*6)

The Versions

21/04 2017

dev-master

9999999-dev https://github.com/weijiansdlx/aliyun

Yii2 extension for Aliyun library

  Sources   Download

GPL-3.0+

The Requires

 

log extension yii2 widget mns oss dayu

21/04 2017

1.0.5

1.0.5.0 https://github.com/weijiansdlx/aliyun

Yii2 extension for Aliyun library

  Sources   Download

GPL-3.0+

The Requires

 

log extension yii2 widget mns oss dayu

08/04 2017

1.0.4

1.0.4.0 https://github.com/weijiansdlx/aliyun

Yii2 extension for Aliyun library

  Sources   Download

GPL-3.0+

The Requires

 

log extension yii2 widget mns oss dayu

23/03 2017

1.0.3

1.0.3.0 https://github.com/weijiansdlx/aliyun

Yii2 extension for Aliyun library

  Sources   Download

GPL-3.0+

The Requires

 

log extension yii2 widget mns oss dayu

23/03 2017

1.0.1

1.0.1.0 https://github.com/weijiansdlx/aliyun

Yii2 extension for Aliyun library

  Sources   Download

GPL-3.0+

The Requires

 

log extension yii2 widget mns oss dayu

17/03 2017

1.0.0

1.0.0.0 https://github.com/weijiansdlx/aliyun

Yii2 extension for Aliyun library

  Sources   Download

GPL-3.0+

The Requires

 

log extension yii2 widget mns oss dayu