mirror of
https://gitee.com/technical-laohu/mpay_v2_webman.git
synced 2026-04-23 10:34:25 +08:00
更新后端基础
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
use support\Request;
|
||||
|
||||
return [
|
||||
'debug' => getenv('APP_DEBUG') ?? true,
|
||||
'debug' => true,
|
||||
'error_reporting' => E_ALL,
|
||||
'default_timezone' => 'Asia/Shanghai',
|
||||
'request_class' => Request::class,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
return [
|
||||
'files' => [
|
||||
base_path() . '/support/functions.php',
|
||||
base_path() . '/support/helpers.php',
|
||||
base_path() . '/support/Request.php',
|
||||
base_path() . '/support/Response.php',
|
||||
]
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
*/
|
||||
|
||||
return [
|
||||
support\bootstrap\Session::class,
|
||||
// support\bootstrap\Session::class,
|
||||
];
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
return [
|
||||
'default' => getenv('CACHE_DRIVER') ?? 'file',
|
||||
'default' => env('CACHE_DRIVER', 'file'),
|
||||
'stores' => [
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
@@ -22,10 +22,10 @@ return [
|
||||
],
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default'
|
||||
'connection' => env('CACHE_REDIS_CONNECTION', 'default')
|
||||
],
|
||||
'array' => [
|
||||
'driver' => 'array'
|
||||
]
|
||||
]
|
||||
];
|
||||
];
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
$builder = new \DI\ContainerBuilder();
|
||||
$builder->addDefinitions(config('dependence', []));
|
||||
$builder->useAutowiring(true);
|
||||
$builder->useAttributes(true);
|
||||
return $builder->build();
|
||||
$builder = new \DI\ContainerBuilder();
|
||||
$builder->addDefinitions(config('dependence', []));
|
||||
$builder->useAutowiring(true);
|
||||
$builder->useAttributes(true);
|
||||
return $builder->build();
|
||||
@@ -1,17 +1,17 @@
|
||||
<?php
|
||||
return [
|
||||
'default' => getenv('DB_CONNECTION') ?? 'mysql',
|
||||
'default' => 'mysql',
|
||||
'connections' => [
|
||||
'mysql' => [
|
||||
'driver' => getenv('DB_DRIVER') ?? 'mysql',
|
||||
'host' => getenv('DB_HOST') ?? '127.0.0.1',
|
||||
'port' => getenv('DB_PORT') ?? '3306',
|
||||
'database' => getenv('DB_DATABASE') ?? '',
|
||||
'username' => getenv('DB_USERNAME') ?? '',
|
||||
'password' => getenv('DB_PASSWORD') ?? '',
|
||||
'driver' => 'mysql',
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', 3306),
|
||||
'database' => env('DB_DATABASE', ''),
|
||||
'username' => env('DB_USERNAME', ''),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_general_ci',
|
||||
'prefix' => getenv('DB_PREFIX') ?? '',
|
||||
'prefix' => '',
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => [
|
||||
@@ -26,4 +26,4 @@ return [
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
];
|
||||
|
||||
48
config/dict.php
Normal file
48
config/dict.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 字典数据配置
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'name' => '性别',
|
||||
'code' => 'gender',
|
||||
'description' => '这是一个性别字典',
|
||||
'list' => [
|
||||
['name' => '女', 'value' => 0],
|
||||
['name' => '男', 'value' => 1],
|
||||
['name' => '其它', 'value' => 2],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => '状态',
|
||||
'code' => 'status',
|
||||
'description' => '状态字段可以用这个',
|
||||
'list' => [
|
||||
['name' => '禁用', 'value' => 0],
|
||||
['name' => '启用', 'value' => 1],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => '岗位',
|
||||
'code' => 'post',
|
||||
'description' => '岗位字段',
|
||||
'list' => [
|
||||
['name' => '总经理', 'value' => 1],
|
||||
['name' => '总监', 'value' => 2],
|
||||
['name' => '人事主管', 'value' => 3],
|
||||
['name' => '开发部主管', 'value' => 4],
|
||||
['name' => '普通职员', 'value' => 5],
|
||||
['name' => '其它', 'value' => 999],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => '任务状态',
|
||||
'code' => 'taskStatus',
|
||||
'description' => '任务状态字段可以用它',
|
||||
'list' => [
|
||||
['name' => '失败', 'value' => 0],
|
||||
['name' => '成功', 'value' => 1],
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -1,12 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* JWT 配置
|
||||
*/
|
||||
return [
|
||||
// JWT 密钥,生产环境建议从 .env 读取
|
||||
'secret' => getenv('JWT_SECRET') ?: 'mpay-secret',
|
||||
// 过期时间(秒)
|
||||
'ttl' => (int)(getenv('JWT_TTL') ?: 7200),
|
||||
// 签名算法
|
||||
'alg' => getenv('JWT_ALG') ?: 'HS256',
|
||||
// JWT 密钥(请在生产环境修改为强随机字符串)
|
||||
'secret' => env('JWT_SECRET', 'mpay-admin-secret-key-change-in-production'),
|
||||
|
||||
// Token 有效期(秒),默认 2 小时
|
||||
'ttl' => (int)env('JWT_TTL', 7200),
|
||||
|
||||
// 加密算法
|
||||
'alg' => env('JWT_ALG', 'HS256'),
|
||||
|
||||
// Token 缓存前缀(用于 Redis 存储)
|
||||
'cache_prefix' => env('JWT_CACHE_PREFIX', 'token_'),
|
||||
];
|
||||
|
||||
|
||||
|
||||
1107
config/menu.php
Normal file
1107
config/menu.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of webman.
|
||||
*
|
||||
@@ -13,9 +12,4 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
return [
|
||||
// 超全局中间件-覆盖插件
|
||||
'@' => [
|
||||
app\common\middleware\Cors::class, //跨域中间件
|
||||
],
|
||||
];
|
||||
return [];
|
||||
28
config/plugin/webman/console/app.php
Normal file
28
config/plugin/webman/console/app.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
return [
|
||||
'enable' => true,
|
||||
|
||||
'build_dir' => BASE_PATH . DIRECTORY_SEPARATOR . 'build',
|
||||
|
||||
'phar_filename' => 'webman.phar',
|
||||
|
||||
'phar_format' => Phar::PHAR, // Phar archive format: Phar::PHAR, Phar::TAR, Phar::ZIP
|
||||
|
||||
'phar_compression' => Phar::NONE, // Compression method for Phar archive: Phar::NONE, Phar::GZ, Phar::BZ2
|
||||
|
||||
'bin_filename' => 'webman.bin',
|
||||
|
||||
'signature_algorithm'=> Phar::SHA256, //set the signature algorithm for a phar and apply it. The signature algorithm must be one of Phar::MD5, Phar::SHA1, Phar::SHA256, Phar::SHA512, or Phar::OPENSSL.
|
||||
|
||||
'private_key_file' => '', // The file path for certificate or OpenSSL private key file.
|
||||
|
||||
'exclude_pattern' => '#^(?!.*(composer.json|/.github/|/.idea/|/.git/|/.setting/|/runtime/|/vendor-bin/|/build/|/vendor/webman/admin/))(.*)$#',
|
||||
|
||||
'exclude_files' => [
|
||||
'.env', 'LICENSE', 'composer.json', 'composer.lock', 'start.php', 'webman.phar', 'webman.bin'
|
||||
],
|
||||
|
||||
'custom_ini' => '
|
||||
memory_limit = 256M
|
||||
',
|
||||
];
|
||||
4
config/plugin/webman/event/app.php
Normal file
4
config/plugin/webman/event/app.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'enable' => true,
|
||||
];
|
||||
17
config/plugin/webman/event/bootstrap.php
Normal file
17
config/plugin/webman/event/bootstrap.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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 [
|
||||
Webman\Event\BootStrap::class,
|
||||
];
|
||||
7
config/plugin/webman/event/command.php
Normal file
7
config/plugin/webman/event/command.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Webman\Event\EventListCommand;
|
||||
|
||||
return [
|
||||
EventListCommand::class
|
||||
];
|
||||
4
config/plugin/webman/redis-queue/app.php
Normal file
4
config/plugin/webman/redis-queue/app.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'enable' => true,
|
||||
];
|
||||
7
config/plugin/webman/redis-queue/command.php
Normal file
7
config/plugin/webman/redis-queue/command.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Webman\RedisQueue\Command\MakeConsumerCommand;
|
||||
|
||||
return [
|
||||
MakeConsumerCommand::class
|
||||
];
|
||||
32
config/plugin/webman/redis-queue/log.php
Normal file
32
config/plugin/webman/redis-queue/log.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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' => [
|
||||
'handlers' => [
|
||||
[
|
||||
'class' => Monolog\Handler\RotatingFileHandler::class,
|
||||
'constructor' => [
|
||||
runtime_path() . '/logs/redis-queue/queue.log',
|
||||
7, //$maxFiles
|
||||
Monolog\Logger::DEBUG,
|
||||
],
|
||||
'formatter' => [
|
||||
'class' => Monolog\Formatter\LineFormatter::class,
|
||||
'constructor' => [null, 'Y-m-d H:i:s', true],
|
||||
],
|
||||
]
|
||||
],
|
||||
]
|
||||
];
|
||||
11
config/plugin/webman/redis-queue/process.php
Normal file
11
config/plugin/webman/redis-queue/process.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
return [
|
||||
'consumer' => [
|
||||
'handler' => Webman\RedisQueue\Process\Consumer::class,
|
||||
'count' => 8, // 可以设置多进程同时消费
|
||||
'constructor' => [
|
||||
// 消费者类目录
|
||||
'consumer_dir' => app_path() . '/jobs'
|
||||
]
|
||||
]
|
||||
];
|
||||
21
config/plugin/webman/redis-queue/redis.php
Normal file
21
config/plugin/webman/redis-queue/redis.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
return [
|
||||
'default' => [
|
||||
'host' => 'redis://' . env('REDIS_HOST', '127.0.0.1') . ':' . env('REDIS_PORT', 6379),
|
||||
'options' => [
|
||||
'auth' => env('REDIS_PASSWORD', ''),
|
||||
'db' => env('QUEUE_REDIS_DATABASE', 0),
|
||||
'prefix' => env('QUEUE_REDIS_PREFIX', 'ma:queue:'),
|
||||
'max_attempts' => 5,
|
||||
'retry_seconds' => 5,
|
||||
],
|
||||
// Connection pool, supports only Swoole or Swow drivers.
|
||||
'pool' => [
|
||||
'max_connections' => 5,
|
||||
'min_connections' => 1,
|
||||
'wait_timeout' => 3,
|
||||
'idle_timeout' => 60,
|
||||
'heartbeat_interval' => 50,
|
||||
]
|
||||
],
|
||||
];
|
||||
@@ -1,20 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MPay V2 支付系统 - Redis配置
|
||||
* Redis 6.0+ 缓存和队列配置
|
||||
* 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 [
|
||||
// 默认Redis连接
|
||||
'default' => [
|
||||
'host' => getenv('REDIS_HOST') ?? '127.0.0.1',
|
||||
'password' => getenv('REDIS_PASSWORD') ?? '',
|
||||
'port' => getenv('REDIS_PORT') ?? 6379,
|
||||
'database' => getenv('REDIS_DATABASE') ?? 0,
|
||||
'password' => env('REDIS_PASSWORD', ''),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'port' => env('REDIS_PORT', 6379),
|
||||
'database' => env('REDIS_DATABASE', 0),
|
||||
'pool' => [
|
||||
'max_connections' => 20,
|
||||
'min_connections' => 5,
|
||||
'max_connections' => 5,
|
||||
'min_connections' => 1,
|
||||
'wait_timeout' => 3,
|
||||
'idle_timeout' => 60,
|
||||
'heartbeat_interval' => 50,
|
||||
],
|
||||
],
|
||||
'cache' => [
|
||||
'password' => env('REDIS_PASSWORD', ''),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'port' => env('REDIS_PORT', 6379),
|
||||
'database' => env('CACHE_REDIS_DATABASE', 1),
|
||||
'prefix' => 'ma:cache:',
|
||||
'pool' => [
|
||||
'max_connections' => 5,
|
||||
'min_connections' => 1,
|
||||
'wait_timeout' => 3,
|
||||
'idle_timeout' => 60,
|
||||
'heartbeat_interval' => 50,
|
||||
|
||||
@@ -17,26 +17,22 @@ use Webman\Route;
|
||||
use support\Response;
|
||||
use support\Request;
|
||||
|
||||
// 匹配所有options路由(CORS 预检请求)
|
||||
Route::options('[{path:.+}]', function (Request $request){
|
||||
$response = response('', 204);
|
||||
return $response->withHeaders([
|
||||
'Access-Control-Allow-Credentials' => 'true',
|
||||
'Access-Control-Allow-Origin' => $request->header('origin', '*'),
|
||||
'Access-Control-Allow-Methods' => $request->header('access-control-request-method', '*'),
|
||||
'Access-Control-Allow-Headers' => $request->header('access-control-request-headers', '*'),
|
||||
]);
|
||||
});
|
||||
|
||||
// 管理后台路由
|
||||
require_once base_path() . '/app/routes/admin.php';
|
||||
|
||||
|
||||
|
||||
// 默认路由兜底
|
||||
Route::fallback(function (Request $request) {
|
||||
// 处理预检请求
|
||||
if (strtoupper($request->method()) === 'OPTIONS') {
|
||||
$response = response('', 204);
|
||||
$response->withHeaders([
|
||||
'Access-Control-Allow-Credentials' => 'true',
|
||||
'Access-Control-Max-Age' => '86400',
|
||||
'Access-Control-Allow-Origin' => $request->header('origin', '*'),
|
||||
'Access-Control-Allow-Methods' => $request->header('access-control-request-method', '*'),
|
||||
'Access-Control-Allow-Headers' => $request->header('access-control-request-headers', '*'),
|
||||
]);
|
||||
return $response;
|
||||
}
|
||||
});
|
||||
// API 路由
|
||||
require_once base_path() . '/app/routes/api.php';
|
||||
|
||||
/**
|
||||
* 关闭默认路由
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of webman.
|
||||
*
|
||||
@@ -19,6 +18,6 @@
|
||||
return [
|
||||
'enable' => true,
|
||||
'middleware' => [ // Static file Middleware
|
||||
app\common\middleware\StaticFile::class,
|
||||
//app\middleware\StaticFile::class,
|
||||
],
|
||||
];
|
||||
];
|
||||
Reference in New Issue
Block a user