2017 © Pedro Peláez
 

library yii2-pushbear

PushBear Yii2 组件,使用 yii2-httpclient 包装 API。并提供 PushBearTarget 日志处理。

image

larryli/yii2-pushbear

PushBear Yii2 组件,使用 yii2-httpclient 包装 API。并提供 PushBearTarget 日志处理。

  • Wednesday, August 9, 2017
  • by larryli
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yii2-pushbear

PushBear Yii2 组件,使用 yii2-httpclient 包装 API。并提供 Target 日志处理。, (*1)

创建消息通道

访问 https://pushbear.ftqq.com/admin/ 使用微信扫码登录后,创建消息通道,获取指定通道的 SendKey。, (*2)

安装

通过 composer 安装。, (*3)

执行命令:, (*4)

php composer.phar require --prefer-dist larryli/yii2-pushbear

或者增加:, (*5)

"larryli/yii2-pushbear": "~1.0"

Yii 组件配置

'components' => [
    'pushBear' => [
        'class' => \larryli\yii\pushbear\PushBear::class,
        'sendKey' => 'your-SendKey',
    ],
],

使用

try {
    Yii::$app->pushBear->sub('标题', "# 内容标题\n\n- 列表 1\n- 列表 2\n\n[链接](https://github.com/larryli/yii2-pushbear)");
} catch (\larryli\yii\pushbear\Exception $e) {
    echo $e->getMessage();
}

日志处理

'components' => [
    'log' => [
         'targets' => [
            [
                'class' => \larryli\yii\pushbear\Target::class,
                // 'pushBear' => 'pushBear',
                'levels' => ['error', 'warning'],
                'except' => [ // except self
                    'larryli\yii\pushbear\*',
                    'yii\httpclient\*',
                ],
                'logVars' => [], // disable $_GET and others
            ],
       ],
   ],
],

Yii2 HttpClient 配置

使用 cURL 库发送 HTTP 消息,此传输需要安装 PHP 'curl' 扩展。, (*6)

'components' => [
    'pushBear' => [
        'class' => \larryli\yii\pushbear\PushBear::class,
        'sendKey' => 'your-SendKey',
        'transport' => \yii\httpclient\CurlTransport::class,
    ],
],

保存 Http 请求日志到指定日志文件。, (*7)

'components' => [
    'log' => [
        'targets' => [
            [
                'class' => \yii\log\FileTarget::class,
                'logFile' => '@runtime/logs/http-request.log',
                'categories' => ['yii\httpclient\*'],
            ],
        ],
    ],
],

使用调试面板查看 Http 请求数据。, (*8)

'bootstrap' => ['debug'],
'modules' => [
    'debug' => [
        'class' => \yii\debug\Module::class,
        'panels' => [
            'httpclient' => [
                'class' => \yii\httpclient\debug\HttpClientPanel::class,
            ],
        ],
    ],
],

The Versions

09/08 2017

dev-master

9999999-dev https://github.com/larryli/yii2-pushbear

PushBear Yii2 组件,使用 yii2-httpclient 包装 API。并提供 PushBearTarget 日志处理。

  Sources   Download

MIT

The Requires