mirror of
https://gitee.com/technical-laohu/mpay_v2_webman.git
synced 2026-03-25 20:24:27 +08:00
更新基础组件
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,6 +7,7 @@
|
||||
/tests/tmp
|
||||
/tests/.phpunit.result.cache
|
||||
.kiro
|
||||
plugin
|
||||
|
||||
# 部署相关文件
|
||||
deploy.bat
|
||||
deploy.bat
|
||||
|
||||
@@ -26,7 +26,25 @@
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"workerman/webman-framework": "^2.1",
|
||||
"monolog/monolog": "^2.0"
|
||||
"monolog/monolog": "^2.0",
|
||||
"php-di/php-di": "7.0",
|
||||
"webman/cache": "^2.1",
|
||||
"webman/redis": "^2.1",
|
||||
"illuminate/events": "^11.0",
|
||||
"webman/redis-queue": "^1.3",
|
||||
"topthink/think-validate": "^3.0",
|
||||
"webman/rate-limiter": "^1.1",
|
||||
"webman/captcha": "^1.0",
|
||||
"webman/event": "^1.0",
|
||||
"vlucas/phpdotenv": "^5.6",
|
||||
"workerman/crontab": "^1.0",
|
||||
"webman/console": "^2.1",
|
||||
"firebase/php-jwt": "^6.0",
|
||||
"illuminate/database": "^11.0",
|
||||
"guzzlehttp/guzzle": "^7.0",
|
||||
"ramsey/uuid": "^4.0",
|
||||
"nesbot/carbon": "^3.0",
|
||||
"webman/admin": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-event": "For better performance. "
|
||||
|
||||
5682
composer.lock
generated
5682
composer.lock
generated
File diff suppressed because it is too large
Load Diff
31
config/cache.php
Normal file
31
config/cache.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of webman.
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the MIT-LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @author walkor<walkor@workerman.net>
|
||||
* @copyright walkor<walkor@workerman.net>
|
||||
* @link http://www.workerman.net/
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
return [
|
||||
'default' => 'file',
|
||||
'stores' => [
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => runtime_path('cache')
|
||||
],
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default'
|
||||
],
|
||||
'array' => [
|
||||
'driver' => 'array'
|
||||
]
|
||||
]
|
||||
];
|
||||
@@ -12,4 +12,8 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
return new Webman\Container;
|
||||
$builder = new \DI\ContainerBuilder();
|
||||
$builder->addDefinitions(config('dependence', []));
|
||||
$builder->useAutowiring(true);
|
||||
$builder->useAttributes(true);
|
||||
return $builder->build();
|
||||
88
config/database.php
Normal file
88
config/database.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* MPay V2 支付系统 - 数据库配置
|
||||
* 基于webman标准配置格式,支持MySQL 5.7+
|
||||
*
|
||||
* 配置说明:
|
||||
* - 字符集:utf8mb4(支持完整的UTF-8字符集,包括emoji)
|
||||
* - 排序规则:utf8mb4_unicode_ci(Unicode标准排序)
|
||||
* - 连接池:支持连接池管理,提高性能(仅支持swoole/swow驱动)
|
||||
* - 读写分离:支持主从数据库配置
|
||||
*/
|
||||
|
||||
return [
|
||||
// 默认数据库连接
|
||||
'default' => env('DB_CONNECTION', 'mysql'),
|
||||
|
||||
// 数据库连接配置
|
||||
'connections' => [
|
||||
// 主数据库配置
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => env('DB_HOST', '192.168.31.200'),
|
||||
'port' => env('DB_PORT', 3306),
|
||||
'database' => env('DB_DATABASE', 'mpay_v2'),
|
||||
'username' => env('DB_USERNAME', 'mpay_v2'),
|
||||
'password' => env('DB_PASSWORD', 'pXfNWELALrwAAt88'),
|
||||
'unix_socket' => '',
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => env('DB_PREFIX', ''),
|
||||
'strict' => true,
|
||||
'engine' => 'InnoDB',
|
||||
'pool' => [
|
||||
'max_connections' => env('DB_POOL_MAX_CONNECTIONS', 20),
|
||||
'min_connections' => env('DB_POOL_MIN_CONNECTIONS', 3),
|
||||
'wait_timeout' => env('DB_POOL_WAIT_TIMEOUT', 3),
|
||||
'idle_timeout' => env('DB_POOL_IDLE_TIMEOUT', 60),
|
||||
'heartbeat_interval' => env('DB_POOL_HEARTBEAT_INTERVAL', 50),
|
||||
],
|
||||
],
|
||||
|
||||
// 读库配置(主从分离)
|
||||
'mysql_read' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => env('DB_READ_HOST', env('DB_HOST', '192.168.31.200')),
|
||||
'port' => env('DB_READ_PORT', env('DB_PORT', 3306)),
|
||||
'database' => env('DB_READ_DATABASE', env('DB_DATABASE', 'mpay_v2')),
|
||||
'username' => env('DB_READ_USERNAME', env('DB_USERNAME', 'mpay_v2')),
|
||||
'password' => env('DB_READ_PASSWORD', env('DB_PASSWORD', 'pXfNWELALrwAAt88')),
|
||||
'unix_socket' => '',
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => env('DB_PREFIX', ''),
|
||||
'strict' => true,
|
||||
'engine' => 'InnoDB',
|
||||
'pool' => [
|
||||
'max_connections' => 15,
|
||||
'min_connections' => 2,
|
||||
'wait_timeout' => 3,
|
||||
'idle_timeout' => 60,
|
||||
'heartbeat_interval' => 50,
|
||||
],
|
||||
],
|
||||
|
||||
// 写库配置(主从分离)
|
||||
'mysql_write' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => env('DB_WRITE_HOST', env('DB_HOST', '192.168.31.200')),
|
||||
'port' => env('DB_WRITE_PORT', env('DB_PORT', 3306)),
|
||||
'database' => env('DB_WRITE_DATABASE', env('DB_DATABASE', 'mpay_v2')),
|
||||
'username' => env('DB_WRITE_USERNAME', env('DB_USERNAME', 'mpay_v2')),
|
||||
'password' => env('DB_WRITE_PASSWORD', env('DB_PASSWORD', 'pXfNWELALrwAAt88')),
|
||||
'unix_socket' => '',
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => env('DB_PREFIX', ''),
|
||||
'strict' => true,
|
||||
'engine' => 'InnoDB',
|
||||
'pool' => [
|
||||
'max_connections' => 10,
|
||||
'min_connections' => 2,
|
||||
'wait_timeout' => 3,
|
||||
'idle_timeout' => 60,
|
||||
'heartbeat_interval' => 50,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
5
config/event.php
Normal file
5
config/event.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
];
|
||||
97
config/redis.php
Normal file
97
config/redis.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* MPay V2 支付系统 - Redis配置
|
||||
* Redis 6.0+ 缓存和队列配置
|
||||
*/
|
||||
|
||||
return [
|
||||
// 默认Redis连接
|
||||
'default' => [
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'password' => env('REDIS_PASSWORD', ''),
|
||||
'port' => env('REDIS_PORT', 6379),
|
||||
'database' => env('REDIS_DATABASE', 0),
|
||||
'pool' => [
|
||||
'max_connections' => env('REDIS_POOL_MAX_CONNECTIONS', 20),
|
||||
'min_connections' => env('REDIS_POOL_MIN_CONNECTIONS', 5),
|
||||
'wait_timeout' => env('REDIS_POOL_WAIT_TIMEOUT', 3),
|
||||
'idle_timeout' => env('REDIS_POOL_IDLE_TIMEOUT', 60),
|
||||
'heartbeat_interval' => env('REDIS_POOL_HEARTBEAT_INTERVAL', 50),
|
||||
],
|
||||
'options' => [
|
||||
'prefix' => env('CACHE_PREFIX', 'mpay_v2_'),
|
||||
],
|
||||
],
|
||||
|
||||
// 缓存专用Redis连接
|
||||
'cache' => [
|
||||
'host' => env('REDIS_CACHE_HOST', env('REDIS_HOST', '127.0.0.1')),
|
||||
'password' => env('REDIS_CACHE_PASSWORD', env('REDIS_PASSWORD', '')),
|
||||
'port' => env('REDIS_CACHE_PORT', env('REDIS_PORT', 6379)),
|
||||
'database' => env('REDIS_CACHE_DATABASE', 1),
|
||||
'pool' => [
|
||||
'max_connections' => 15,
|
||||
'min_connections' => 3,
|
||||
'wait_timeout' => 3,
|
||||
'idle_timeout' => 60,
|
||||
'heartbeat_interval' => 50,
|
||||
],
|
||||
'options' => [
|
||||
'prefix' => env('CACHE_PREFIX', 'mpay_v2_cache_'),
|
||||
],
|
||||
],
|
||||
|
||||
// 队列专用Redis连接
|
||||
'queue' => [
|
||||
'host' => env('REDIS_QUEUE_HOST', env('REDIS_HOST', '127.0.0.1')),
|
||||
'password' => env('REDIS_QUEUE_PASSWORD', env('REDIS_PASSWORD', '')),
|
||||
'port' => env('REDIS_QUEUE_PORT', env('REDIS_PORT', 6379)),
|
||||
'database' => env('REDIS_QUEUE_DATABASE', 2),
|
||||
'pool' => [
|
||||
'max_connections' => 10,
|
||||
'min_connections' => 2,
|
||||
'wait_timeout' => 3,
|
||||
'idle_timeout' => 60,
|
||||
'heartbeat_interval' => 50,
|
||||
],
|
||||
'options' => [
|
||||
'prefix' => env('QUEUE_PREFIX', 'mpay_v2_queue_'),
|
||||
],
|
||||
],
|
||||
|
||||
// 会话存储Redis连接
|
||||
'session' => [
|
||||
'host' => env('REDIS_SESSION_HOST', env('REDIS_HOST', '127.0.0.1')),
|
||||
'password' => env('REDIS_SESSION_PASSWORD', env('REDIS_PASSWORD', '')),
|
||||
'port' => env('REDIS_SESSION_PORT', env('REDIS_PORT', 6379)),
|
||||
'database' => env('REDIS_SESSION_DATABASE', 3),
|
||||
'pool' => [
|
||||
'max_connections' => 10,
|
||||
'min_connections' => 2,
|
||||
'wait_timeout' => 3,
|
||||
'idle_timeout' => 60,
|
||||
'heartbeat_interval' => 50,
|
||||
],
|
||||
'options' => [
|
||||
'prefix' => 'mpay_v2_session_',
|
||||
],
|
||||
],
|
||||
|
||||
// JWT黑名单Redis连接
|
||||
'jwt_blacklist' => [
|
||||
'host' => env('REDIS_JWT_HOST', env('REDIS_HOST', '127.0.0.1')),
|
||||
'password' => env('REDIS_JWT_PASSWORD', env('REDIS_PASSWORD', '')),
|
||||
'port' => env('REDIS_JWT_PORT', env('REDIS_PORT', 6379)),
|
||||
'database' => env('REDIS_JWT_DATABASE', 4),
|
||||
'pool' => [
|
||||
'max_connections' => 5,
|
||||
'min_connections' => 1,
|
||||
'wait_timeout' => 3,
|
||||
'idle_timeout' => 60,
|
||||
'heartbeat_interval' => 50,
|
||||
],
|
||||
'options' => [
|
||||
'prefix' => 'mpay_v2_jwt_blacklist_',
|
||||
],
|
||||
],
|
||||
];
|
||||
71
webman
Normal file
71
webman
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Webman\Config;
|
||||
use Webman\Console\Command;
|
||||
use Webman\Console\Util;
|
||||
use support\Container;
|
||||
use Dotenv\Dotenv;
|
||||
|
||||
if (!Phar::running()) {
|
||||
chdir(__DIR__);
|
||||
}
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
if (!$appConfigFile = config_path('app.php')) {
|
||||
throw new RuntimeException('Config file not found: app.php');
|
||||
}
|
||||
|
||||
if (class_exists(Dotenv::class) && file_exists(run_path('.env'))) {
|
||||
if (method_exists(Dotenv::class, 'createUnsafeImmutable')) {
|
||||
Dotenv::createUnsafeImmutable(run_path())->load();
|
||||
} else {
|
||||
Dotenv::createMutable(run_path())->load();
|
||||
}
|
||||
}
|
||||
|
||||
$appConfig = require $appConfigFile;
|
||||
if ($timezone = $appConfig['default_timezone'] ?? '') {
|
||||
date_default_timezone_set($timezone);
|
||||
}
|
||||
|
||||
if ($errorReporting = $appConfig['error_reporting'] ?? '') {
|
||||
error_reporting($errorReporting);
|
||||
}
|
||||
|
||||
if (!in_array($argv[1] ?? '', ['start', 'restart', 'stop', 'status', 'reload', 'connections'])) {
|
||||
require_once __DIR__ . '/support/bootstrap.php';
|
||||
} else {
|
||||
if (class_exists('Support\App')) {
|
||||
Support\App::loadAllConfig(['route']);
|
||||
} else {
|
||||
Config::reload(config_path(), ['route', 'container']);
|
||||
}
|
||||
}
|
||||
|
||||
$cli = new Command();
|
||||
$cli->setName('webman cli');
|
||||
$cli->installInternalCommands();
|
||||
if (is_dir($command_path = Util::guessPath(app_path(), '/command', true))) {
|
||||
$cli->installCommands($command_path);
|
||||
}
|
||||
|
||||
foreach (config('plugin', []) as $firm => $projects) {
|
||||
if (isset($projects['app'])) {
|
||||
foreach (['', '/app'] as $app) {
|
||||
if ($command_str = Util::guessPath(base_path() . "/plugin/$firm{$app}", 'command')) {
|
||||
$command_path = base_path() . "/plugin/$firm{$app}/$command_str";
|
||||
$cli->installCommands($command_path, "plugin\\$firm" . str_replace('/', '\\', $app) . "\\$command_str");
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($projects as $name => $project) {
|
||||
if (!is_array($project)) {
|
||||
continue;
|
||||
}
|
||||
$project['command'] ??= [];
|
||||
array_walk($project['command'], [$cli, 'createCommandInstance']);
|
||||
}
|
||||
}
|
||||
|
||||
$cli->run();
|
||||
Reference in New Issue
Block a user