2017 © Pedro Peláez
 

yii2-extension yii2-easy-wechat

Easywechat sdk for yii2 php framework

image

tsingsun/yii2-easy-wechat

Easywechat sdk for yii2 php framework

  • Tuesday, July 11, 2017
  • by tsingsun
  • Repository
  • 1 Watchers
  • 3 Stars
  • 87 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 12 % Grown

The README.md

Yii2 EasyWechat

wechat extension for Yii2. this is base on EasyWechat, (*1)

Latest Stable Version Build Status Total Downloads, (*2)

Installation

    composer require --prefer-dist tsingsun/yii2-easy-wechat

Configuration

'components' => [       
        'cache' => [
            'class'=>'yii\caching\FileCache',
            'keyPrefix' => 'yak',
        ],
        'wechat'=>[
            'class'=>'yii\easyWechat\Wechat',
            //the config is all most match the easyWechat office's config,
            //the diffenrece please see Notice
            'config'=>[                
                'debug'  => true,                
                'app_id'=>'',
                'secret'=>'',
                'token'=>'',
                'aes_key'=>'',
                'payment'=>[                   
                    'merchant_id'=>'',
                    'key'=>'',                    
                    'cert_path'=>'',
                    'key_path'=>'',                    
                    'notify_url'=>''

                ],               
                'oauth' => [
                    'scopes'   => ['snsapi_userinfo'],
                    'callback' => '/examples/oauth_callback.php',
                ],
                'guzzle' => [
                    'timeout' => 3.0, //
                    //'verify' => false, // close SSL verify(not suggust!!!)
                ],                
                /**
                 * Cache,if not set ,use Yii default config cache
                 */
                'cache'=>[

                ],
            ],
        ],
        'log'=>[
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'maxFileSize'=> 200,
                    'levels' => [],
                    'logVars' => [],
                    'logFile' => '@runtime/logs/'.date('ymd').'.log',
                ],
            ]
        ],
    ]

Notice

There are some change to better match for yii * use Yii Logger component instead of EasyWechat default logger; * use Yii Cache component instead of EasyWechat default Cache that based on \Doctrine\Common\Cache\Cache., (*3)

how to use

    //after configure,use it as bellow
    /**
    * @var Wechat $wechat use @var doc attribute to code lint
    **/
    $wechat = Yii::$app->get('wechat');
    //$wechat->app is Easywechat's Application instance
    $wechat->app->server->setMessageHandler(function ($message) {
                return "hello world!welcome!";
            });
    $wechat->app->server()->send();

how to Test

In the unit test process, also discovered the WeChat development debugging egg pain, because also combed the test better practice The tests are centered in the test directory. Go to the directory 测试说明, (*4)

The Versions

11/07 2017

dev-master

9999999-dev

Easywechat sdk for yii2 php framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by QingShan li

11/07 2017

0.1

0.1.0.0

Easywechat sdk for yii2 php framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by QingShan li