seffeng / laravel-wechat by seffeng

PHP laravel extension wechat
629
0
2
Package Data
Maintainer Username: seffeng
Maintainer Contact: save.zxf@gmail.com (seffeng)
Package Create Date: 2021-02-24
Package Last Update: 2021-11-05
Language: PHP
License: MIT
Last Refreshed: 2024-11-09 15:08:38
Package Statistics
Total Downloads: 629
Monthly Downloads: 4
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Laravel Wechat

安装

# 安装
$ composer require seffeng/laravel-wechat
Laravel
# 1、生成配置文件
$ php artisan vendor:publish --tag="wechat"

# 2、修改配置文件 /config/wechat.php,或 .env
lumen
# 1、复制扩展内配置文件 /config/wechat.php 到项目配置目录 /config

# 2、修改配置文件 /config/wechat.php,或 .env

# 3、将以下代码段添加到 /bootstrap/app.php 文件中的 Providers 部分
$app->register(Seffeng\LaravelWechat\WechatServiceProvider::class);

# 4、/bootstrap/app.php 添加配置加载代码
$app->configure('wechat');

示例

# 客户端示例
use Seffeng\Wechat\Exceptions\WechatException;
use Seffeng\LaravelWechat\Facades\Wechat;

class SiteController extends Controller
{
    public function test()
    {
        try {
            var_dump(Wechat::getAccessToken());
            var_dump(Wechat::getJsapiTicket());
            print_r(Wechat::getSignPackage('https://url.cn'));
        } catch (WechatException $e) {
            var_dump($e->getMessage());
        } catch (\Exception $e) {
            var_dump($e->getMessage());
        }
    }
}

备注

1、测试脚本 tests/WechatTest.php 仅作为示例供参考。