Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Feb 15, 2023
1 parent d2c615c commit 2ef8b18
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 111 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/vendor/
composer.lock
.php-cs-fixer.cache
.idea
.ideacghooks.lock

cghooks.lock
12 changes: 0 additions & 12 deletions .php-cs-fixer.php

This file was deleted.

122 changes: 63 additions & 59 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,63 +1,67 @@
{
"name": "overtrue/laravel-wechat",
"description": "微信 SDK for Laravel",
"keywords": ["wechat", "weixin","laravel", "sdk"],
"license": "MIT",
"authors": [
{
"name": "overtrue",
"email": "[email protected]"
}
],
"require": {
"illuminate/container": "^9.0|^10.0",
"w7corp/easywechat": "^6.0.0"
},
"require-dev": {
"laravel/framework": "^9.0|^10.0",
"friendsofphp/php-cs-fixer": "^3.1",
"jetbrains/phpstorm-attributes": "^1.0"
},
"autoload": {
"psr-4": {
"Overtrue\\LaravelWeChat\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Overtrue\\LaravelWeChat\\ServiceProvider"
]
},
"hooks": {
"pre-commit": [
"composer check-style",
"composer test"
],
"pre-push": [
"composer check-style"
]
}
},
"scripts": {
"post-update-cmd": [
"cghooks remove",
"cghooks add --ignore-lock",
"cghooks update"
],
"post-merge": "composer install",
"post-install-cmd": [
"cghooks remove",
"cghooks add --ignore-lock",
"cghooks update"
],
"check-style": "php-cs-fixer fix --using-cache=no --diff --dry-run --allow-risky=yes --ansi",
"fix-style": "php-cs-fixer fix --using-cache=no --allow-risky=yes --ansi",
"test": "phpunit --colors"
"name": "overtrue/laravel-wechat",
"description": "微信 SDK for Laravel",
"keywords": [
"wechat",
"weixin",
"laravel",
"sdk"
],
"license": "MIT",
"authors": [
{
"name": "overtrue",
"email": "[email protected]"
}
],
"require": {
"illuminate/container": "^9.0|^10.0",
"w7corp/easywechat": "^6.0.0"
},
"require-dev": {
"laravel/framework": "^10.0",
"jetbrains/phpstorm-attributes": "^1.0",
"brainmaestro/composer-git-hooks": "dev-master",
"laravel/pint": "^1.5"
},
"autoload": {
"psr-4": {
"Overtrue\\LaravelWeChat\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Overtrue\\LaravelWeChat\\ServiceProvider"
]
},
"config": {
"allow-plugins": {
"easywechat-composer/easywechat-composer": true
}
"hooks": {
"pre-commit": [
"composer check-style"
],
"pre-push": [
"composer check-style"
]
}
},
"scripts": {
"post-update-cmd": [
"cghooks remove",
"cghooks add --ignore-lock",
"cghooks update"
],
"post-merge": "composer install",
"post-install-cmd": [
"cghooks remove",
"cghooks add --ignore-lock",
"cghooks update"
],
"check-style": "vendor/bin/pint --test",
"fix-style": "vendor/bin/pint"
},
"config": {
"allow-plugins": {
"easywechat-composer/easywechat-composer": true
}
}
}
50 changes: 25 additions & 25 deletions config/easywechat.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* 默认配置,将会合并到各模块中
*/
'defaults' => [
'defaults' => [
'http' => [
'timeout' => 5.0,
],
Expand All @@ -15,9 +15,9 @@
*/
'official_account' => [
'default' => [
'app_id' => env('WECHAT_OFFICIAL_ACCOUNT_APPID', ''), // AppID
'secret' => env('WECHAT_OFFICIAL_ACCOUNT_SECRET', ''), // AppSecret
'token' => env('WECHAT_OFFICIAL_ACCOUNT_TOKEN', ''), // Token
'app_id' => env('WECHAT_OFFICIAL_ACCOUNT_APPID', ''), // AppID
'secret' => env('WECHAT_OFFICIAL_ACCOUNT_SECRET', ''), // AppSecret
'token' => env('WECHAT_OFFICIAL_ACCOUNT_TOKEN', ''), // Token
'aes_key' => env('WECHAT_OFFICIAL_ACCOUNT_AES_KEY', ''), // EncodingAESKey

/*
Expand All @@ -33,10 +33,10 @@
// 'enforce_https' => true,
// ],

/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26
*/
/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26
*/
//'http' => [
// 'timeout' => 5.0,
// // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri
Expand All @@ -55,10 +55,10 @@
// 'token' => env('WECHAT_OPEN_PLATFORM_TOKEN', ''),
// 'aes_key' => env('WECHAT_OPEN_PLATFORM_AES_KEY', ''),

/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26
*/
/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26
*/
// 'http' => [
// 'timeout' => 5.0,
// // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri
Expand All @@ -77,10 +77,10 @@
// 'token' => env('WECHAT_MINI_APP_TOKEN', ''),
// 'aes_key' => env('WECHAT_MINI_APP_AES_KEY', ''),

/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26
*/
/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26
*/
// 'http' => [
// 'timeout' => 5.0,
// // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri
Expand Down Expand Up @@ -114,7 +114,7 @@
//
// // v3 API 秘钥
// //'secret_key' => '43A03299A3C3FED3D8CE7B820Fxxxxx',
//
//
// // 注意 此处为微信支付平台证书 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/wechatpay5_1.shtml
// 'platform_certs' => [
// '/data/private/certs/platform_key.pem',
Expand All @@ -132,10 +132,10 @@
// 'token' => env('WECHAT_WORK_TOKEN', ''),
// 'aes_key' => env('WECHAT_WORK_AES_KEY', ''),

/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26
*/
/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26
*/
// 'http' => [
// 'timeout' => 5.0,
// // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri
Expand All @@ -154,10 +154,10 @@
// 'token' => env('WECHAT_OPEN_WORK_TOKEN', ''),
// 'aes_key' => env('WECHAT_OPEN_WORK_AES_KEY', ''),

/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26
*/
/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26
*/
// 'http' => [
// 'timeout' => 5.0,
// // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri
Expand Down
12 changes: 2 additions & 10 deletions src/Middleware/OAuthAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,8 @@
*/
class OAuthAuthenticate
{
/**
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string $account
* @param string|null $scope
*
* @return mixed
*/
public function handle(
\Illuminate\Http\Request $request,
Request $request,
Closure $next,
string $account = 'default',
string $scope = null,
Expand Down Expand Up @@ -92,7 +84,7 @@ protected function getIntendUrl(Request $request, bool $https = false): string

protected function getRedirectUrl(Request $request, bool $https = false): string
{
if (!$https) {
if (! $https) {
return $request->fullUrl();
}

Expand Down
5 changes: 2 additions & 3 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use EasyWeChat\OpenWork\Application as OpenWork;
use EasyWeChat\Pay\Application as Payment;
use EasyWeChat\Work\Application as Work;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;

class ServiceProvider extends LaravelServiceProvider
Expand Down Expand Up @@ -51,7 +50,7 @@ public function register()
continue;
}

if (!empty(config('easywechat.'.$name.'.app_id')) || !empty(config('easywechat.'.$name.'.corp_id'))) {
if (! empty(config('easywechat.'.$name.'.app_id')) || ! empty(config('easywechat.'.$name.'.corp_id'))) {
$accounts = [
'default' => config('easywechat.'.$name),
];
Expand All @@ -61,7 +60,7 @@ public function register()
}

foreach ($accounts as $account => $config) {
$this->app->bind("easywechat.{$name}.{$account}", function ($laravelApp) use ($name, $account, $config, $class) {
$this->app->bind("easywechat.{$name}.{$account}", function ($laravelApp) use ($config, $class) {
$app = new $class(array_merge(config('easywechat.defaults', []), $config));

if (\is_callable([$app, 'setCache'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/HandleOpenPlatformServerEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use EasyWeChat\OpenPlatform\Application;
use Overtrue\LaravelWeChat\Events\OpenPlatform\Authorized;
use Overtrue\LaravelWeChat\Events\OpenPlatform\Unauthorized;
use Overtrue\LaravelWeChat\Events\OpenPlatform\AuthorizeUpdated;
use Overtrue\LaravelWeChat\Events\OpenPlatform\Unauthorized;
use Overtrue\LaravelWeChat\Events\OpenPlatform\VerifyTicketRefreshed;

trait HandleOpenPlatformServerEvents
Expand Down

0 comments on commit 2ef8b18

Please sign in to comment.