WeChat applet php backend interface lightweight version
####Original intention: There are a lot of useful WeChat SDKs, but I have not written them myself.
However, the easy-to-use SDK is large and comprehensive, and has a lot of dependencies. It's a bit wasteful for applications with very small business.
At that time, due to business needs, I took advantage of the trend to make small programs. However, the actual back-end interface usage was very small, so I packaged the interfaces I planned to use myself.
Then, I plan to take it apart and share it.
##Install:
composer require yingouqlj/wechat-mini-program-lite
##Basic usage:
<?php
use Yingou MiniProgram MiniProgram ;
$ config =[
' appId ' => ' appid ' ,
' secret ' => ' secret '
];
$ program = new MiniProgram ( $ config );
//创建Qrcode
$ program -> createQrCode -> create ( ' /page?id=1 ' , 120 );
## Recommended usage: Add a configuration to inherit Config
Implement the reading and writing of token in it, overwriting the original method.
<?php
class ProgramConfig extends Yingou MiniProgram Config{
public function getAccessToken ()
{
//覆盖掉原来的方法在这里 读取token
}
public function setAccessToken ( $ token , $ expires = 0 )
{
//覆盖写入 如 redis
}
}
use Yingou MiniProgram MiniProgram ;
$ program = new MiniProgram ( new ProgramConfig ());
$ program -> createQrCode -> create ( ' /page?id=1 ' , 120 );
##interface
####Progress: Start the project first and then improve it slowly. We will also consider introducing other dependency packages later. The first version is lightweight.