master
李春波 2 years ago
parent 21411fc831
commit fbe98bd4ef
  1. 8
      app/common/service/BaseServices.php
  2. 7
      app/common/service/wechat/OpenPlatform.php
  3. 47
      app/controller/IndexController.php
  4. 8
      app/service/BaseServices.php
  5. 14
      app/view/index/view.html
  6. 20
      app/wechat/controller/IndexController.php
  7. 10
      app/wechat/middleware/StaticFile.php
  8. 2
      app/wechat/model/Test.php
  9. 4
      composer.json
  10. 292
      composer.lock
  11. 1
      config/bootstrap.php
  12. 22
      config/database.php

@ -0,0 +1,8 @@
<?php
namespace app\common\service;
class BaseServices
{
}

@ -1,13 +1,14 @@
<?php
namespace app\service\wechat;
namespace app\common\service\wechat;
use app\service\BaseServices;
use app\common\service\BaseServices;
use EasyWeChat\Factory;
use EasyWeChat\OpenPlatform\Application;
use Symfony\Component\HttpFoundation\HeaderBag;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
class OpenPlatform extends BaseServices {
public $app;
public Application $app;
public function __construct($config)
{

@ -1,47 +0,0 @@
<?php
namespace app\controller;
use support\Request;
use EasyWeChat\Factory;
use app\service\wechat\OpenPlatform;
class IndexController
{
public function index(Request $request)
{
$xml = $request->rawBody();
$xml = simplexml_load_string($xml);
if (empty($xml)) return '请求体为空';
$appId = (string)$xml->AppId;
$openPlatformConfig = config("wechat.open_platform.$appId");
$app = new OpenPlatform($openPlatformConfig);
return $app->handle($request);
}
public function view(Request $request)
{
// $cache = $this->getCache()->set('easywechat.open_platform.verify_ticket.wx3a67b967164b59d1', '', 3600);
// return $this->getCache()->get('easywechat.open_platform.verify_ticket.wx3a67b967164b59d1');
// if (!$this->getCache()->has('testcache')) {
// return 'cache failed';
// }
// echo json_encode($this->getCache(),true);
// return 123;
$config = [
'app_id' => 'wx3a67b967164b59d1',
'secret' => '604cf7409d1ace34a1fb8226cef89c30',
'token' => 'chunboli888',
'aes_key' => 'rvEuQLD5QqVqWQeHHTMvxIW8GtOBLIhVzZh6uGL2Cqr'
];
$openPlatform = Factory::openPlatform($config);
$Authorizers = $openPlatform->getAuthorizer('wx15d93c0b30202ad5');
return json($Authorizers);
return view('index/view', ['name' => 'webman']);
}
public function json(Request $request)
{
return json(['code' => 0, 'msg' => 'ok']);
}
}

@ -1,8 +0,0 @@
<?php
namespace app\service;
class BaseServices
{
}

@ -1,14 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="/favicon.ico"/>
<title>webman</title>
</head>
<body>
hello <?=htmlspecialchars($name)?>
</body>
</html>

@ -0,0 +1,20 @@
<?php
namespace app\wechat\controller;
use app\common\service\wechat\OpenPlatform;
use EasyWeChat\Factory;
use support\Request;
class IndexController
{
public function index(Request $request)
{
$xml = $request->rawBody();
$xml = simplexml_load_string($xml);
if (empty($xml)) return '请求体为空';
$appId = (string)$xml->AppId;
$openPlatformConfig = config("wechat.open_platform.$appId");
$app = new OpenPlatform($openPlatformConfig);
return $app->handle($request);
}
}

@ -12,11 +12,11 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace app\middleware;
namespace app\wechat\middleware;
use Webman\MiddlewareInterface;
use Webman\Http\Response;
use Webman\Http\Request;
use Webman\Http\Response;
use Webman\MiddlewareInterface;
/**
* Class StaticFile
@ -33,10 +33,10 @@ class StaticFile implements MiddlewareInterface
/** @var Response $response */
$response = $next($request);
// Add cross domain HTTP header
/*$response->withHeaders([
$response->withHeaders([
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Credentials' => 'true',
]);*/
]);
return $response;
}
}

@ -1,6 +1,6 @@
<?php
namespace app\model;
namespace app\wechat\model;
use support\Model;

@ -29,7 +29,9 @@
"monolog/monolog": "^2.0",
"overtrue/wechat": "5.9.1",
"vlucas/phpdotenv": "^5.6",
"ext-simplexml": "*"
"ext-simplexml": "*",
"webman/think-orm": "^1.1",
"tinywan/jwt": "^1.8"
},
"suggest": {
"ext-event": "For better performance. "

292
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6b33926f295f491d627ab25c2fb7fe10",
"content-hash": "c26c61decbc3d54cfca2980798fcc13d",
"packages": [
{
"name": "easywechat-composer/easywechat-composer",
@ -54,6 +54,59 @@
},
"time": "2021-07-05T04:03:22+00:00"
},
{
"name": "firebase/php-jwt",
"version": "v6.9.0",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/firebase/php-jwt/v6.9.0/firebase-php-jwt-v6.9.0.zip",
"reference": "f03270e63eaccf3019ef0f32849c497385774e11",
"shasum": ""
},
"require": {
"php": "^7.4||^8.0"
},
"require-dev": {
"guzzlehttp/guzzle": "^6.5||^7.4",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5",
"psr/cache": "^1.0||^2.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0"
},
"suggest": {
"ext-sodium": "Support EdDSA (Ed25519) signatures",
"paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present"
},
"type": "library",
"autoload": {
"psr-4": {
"Firebase\\JWT\\": "src"
}
},
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Neuman Vong",
"email": "neuman+pear@twilio.com",
"role": "Developer"
},
{
"name": "Anant Narayanan",
"email": "anant@php.net",
"role": "Developer"
}
],
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
"homepage": "https://github.com/firebase/php-jwt",
"keywords": [
"jwt",
"php"
],
"time": "2023-10-05T00:24:42+00:00"
},
{
"name": "graham-campbell/result-type",
"version": "v1.1.2",
@ -526,14 +579,9 @@
{
"name": "nikic/fast-route",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/FastRoute.git",
"reference": "181d480e08d9476e61381e04a71b34dc0432e812"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/FastRoute/zipball/181d480e08d9476e61381e04a71b34dc0432e812",
"url": "https://mirrors.cloud.tencent.com/repository/composer/nikic/fast-route/v1.3.0/nikic-fast-route-v1.3.0.zip",
"reference": "181d480e08d9476e61381e04a71b34dc0432e812",
"shasum": ""
},
@ -552,7 +600,6 @@
"FastRoute\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
@ -567,10 +614,6 @@
"router",
"routing"
],
"support": {
"issues": "https://github.com/nikic/FastRoute/issues",
"source": "https://github.com/nikic/FastRoute/tree/master"
},
"time": "2018-02-13T20:26:39+00:00"
},
{
@ -900,14 +943,9 @@
{
"name": "psr/container",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
"url": "https://mirrors.tencent.com/repository/composer/psr/container/2.0.2/psr-container-2.0.2.zip",
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
"shasum": ""
},
@ -925,7 +963,6 @@
"Psr\\Container\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -944,10 +981,6 @@
"container-interop",
"psr"
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/2.0.2"
},
"time": "2021-11-05T16:47:00+00:00"
},
{
@ -1163,14 +1196,9 @@
{
"name": "psr/log",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
"url": "https://mirrors.cloud.tencent.com/repository/composer/psr/log/1.1.4/psr-log-1.1.4.zip",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
"shasum": ""
},
@ -1188,7 +1216,6 @@
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -1205,22 +1232,14 @@
"psr",
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/1.1.4"
},
"time": "2021-05-03T11:20:27+00:00"
},
{
"name": "psr/simple-cache",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/simple-cache.git",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"url": "https://mirrors.tencent.com/repository/composer/psr/simple-cache/1.0.1/psr-simple-cache-1.0.1.zip",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"shasum": ""
},
@ -1238,7 +1257,6 @@
"Psr\\SimpleCache\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -1256,9 +1274,6 @@
"psr-16",
"simple-cache"
],
"support": {
"source": "https://github.com/php-fig/simple-cache/tree/master"
},
"time": "2017-10-23T01:57:42+00:00"
},
{
@ -2315,6 +2330,124 @@
],
"time": "2023-07-20T07:21:16+00:00"
},
{
"name": "tinywan/jwt",
"version": "v1.8.5",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/tinywan/jwt/v1.8.5/tinywan-jwt-v1.8.5.zip",
"reference": "1dc980750e19f5df2a20cf763a0c01c15c60dd29",
"shasum": ""
},
"require": {
"ext-json": "*",
"firebase/php-jwt": "^6.8",
"php": "^7.1||^8.0",
"workerman/webman-framework": "^1.2.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.6",
"illuminate/database": "^8.83",
"mockery/mockery": "^1.5",
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9.0",
"topthink/think-orm": "^2.0",
"vimeo/psalm": "^4.22",
"workerman/webman": "^1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Tinywan\\Jwt\\": "src"
}
},
"license": [
"MIT"
],
"description": "JSON Web Token (JWT) for webman plugin",
"time": "2023-11-16T12:20:56+00:00"
},
{
"name": "topthink/think-helper",
"version": "v3.1.6",
"dist": {
"type": "zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/topthink/think-helper/v3.1.6/topthink-think-helper-v3.1.6.zip",
"reference": "769acbe50a4274327162f9c68ec2e89a38eb2aff",
"shasum": ""
},
"require": {
"php": ">=7.1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"type": "library",
"autoload": {
"files": [
"src/helper.php"
],
"psr-4": {
"think\\": "src"
}
},
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "yunwuxin",
"email": "448901948@qq.com"
}
],
"description": "The ThinkPHP6 Helper Package",
"time": "2021-12-15T04:27:55+00:00"
},
{
"name": "topthink/think-orm",
"version": "v2.0.61",
"dist": {
"type": "zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/topthink/think-orm/v2.0.61/topthink-think-orm-v2.0.61.zip",
"reference": "10528ebf4a5106b19c3bac9c6deae7a67ff49de6",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-pdo": "*",
"php": ">=7.1.0",
"psr/log": "^1.0|^2.0",
"psr/simple-cache": "^1.0|^2.0",
"topthink/think-helper": "^3.1"
},
"require-dev": {
"phpunit/phpunit": "^7|^8|^9.5"
},
"type": "library",
"autoload": {
"files": [
"stubs/load_stubs.php"
],
"psr-4": {
"think\\": "src"
}
},
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "liu21st",
"email": "liu21st@gmail.com"
}
],
"description": "think orm",
"keywords": [
"database",
"orm"
],
"time": "2023-04-20T14:27:51+00:00"
},
{
"name": "vlucas/phpdotenv",
"version": "v5.6.0",
@ -2380,17 +2513,36 @@
"time": "2023-11-12T22:43:29+00:00"
},
{
"name": "workerman/webman-framework",
"version": "v1.5.11",
"source": {
"type": "git",
"url": "https://github.com/walkor/webman-framework.git",
"reference": "a77eb7fa7147fb6793886e08aa81a0de2c1cfa12"
"name": "webman/think-orm",
"version": "v1.1.1",
"dist": {
"type": "zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/webman/think-orm/v1.1.1/webman-think-orm-v1.1.1.zip",
"reference": "9f1e525c5c4b5a2e1eee6a4f82ef5d23c69139a2",
"shasum": ""
},
"require": {
"topthink/think-orm": "^2.0.53 || ^3.0.0",
"workerman/webman-framework": "^1.2.1"
},
"type": "library",
"autoload": {
"psr-4": {
"Webman\\ThinkOrm\\": "src"
}
},
"license": [
"MIT"
],
"time": "2023-04-23T14:40:18+00:00"
},
{
"name": "workerman/webman-framework",
"version": "v1.5.13",
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/walkor/webman-framework/zipball/a77eb7fa7147fb6793886e08aa81a0de2c1cfa12",
"reference": "a77eb7fa7147fb6793886e08aa81a0de2c1cfa12",
"url": "https://mirrors.cloud.tencent.com/repository/composer/workerman/webman-framework/v1.5.13/workerman-webman-framework-v1.5.13.zip",
"reference": "699c9c9509d472679fa1d8461b9a9bb58fbe79a7",
"shasum": ""
},
"require": {
@ -2414,7 +2566,6 @@
"Support\\Exception\\": "./src/support/exception"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -2432,26 +2583,14 @@
"High Performance",
"http service"
],
"support": {
"email": "walkor@workerman.net",
"forum": "https://wenda.workerman.net/",
"issues": "https://github.com/walkor/webman/issues",
"source": "https://github.com/walkor/webman-framework",
"wiki": "https://doc.workerman.net/"
},
"time": "2023-10-31T09:09:49+00:00"
"time": "2023-11-16T04:06:19+00:00"
},
{
"name": "workerman/workerman",
"version": "v4.1.13",
"source": {
"type": "git",
"url": "https://github.com/walkor/workerman.git",
"reference": "807780ff672775fcd08f89e573a2824e939021ce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/walkor/workerman/zipball/807780ff672775fcd08f89e573a2824e939021ce",
"url": "https://mirrors.cloud.tencent.com/repository/composer/workerman/workerman/v4.1.13/workerman-workerman-v4.1.13.zip",
"reference": "807780ff672775fcd08f89e573a2824e939021ce",
"shasum": ""
},
@ -2467,7 +2606,6 @@
"Workerman\\": "./"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -2485,23 +2623,6 @@
"asynchronous",
"event-loop"
],
"support": {
"email": "walkor@workerman.net",
"forum": "http://wenda.workerman.net/",
"issues": "https://github.com/walkor/workerman/issues",
"source": "https://github.com/walkor/workerman",
"wiki": "http://doc.workerman.net/"
},
"funding": [
{
"url": "https://opencollective.com/workerman",
"type": "open_collective"
},
{
"url": "https://www.patreon.com/walkor",
"type": "patreon"
}
],
"time": "2023-07-31T05:57:25+00:00"
}
],
@ -2512,7 +2633,8 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=7.2"
"php": ">=7.2",
"ext-simplexml": "*"
},
"platform-dev": [],
"plugin-api-version": "2.6.0"

@ -15,4 +15,5 @@
return [
support\bootstrap\Session::class,
support\bootstrap\LaravelDb::class,
Webman\ThinkOrm\ThinkOrm::class,
];

@ -12,4 +12,24 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
return [];
return [
// 默认数据库
'default' => 'mysql',
// 各种数据库配置
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => getenv('DB_HOST'),
'port' => getenv('DB_PORT'),
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USER'),
'password' => getenv('DB_PASSWORD'),
'unix_socket' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
],
];
Loading…
Cancel
Save