first commit

This commit is contained in:
wushumin
2026-04-16 11:17:18 +08:00
commit 5b9c398e68
98 changed files with 8701 additions and 0 deletions

26
config/app.php Normal file
View File

@@ -0,0 +1,26 @@
<?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
*/
use support\Request;
return [
'debug' => true,
'error_reporting' => E_ALL,
'default_timezone' => 'Asia/Shanghai',
'request_class' => Request::class,
'public_path' => base_path() . DIRECTORY_SEPARATOR . 'public',
'runtime_path' => base_path(false) . DIRECTORY_SEPARATOR . 'runtime',
'controller_suffix' => 'Controller',
'controller_reuse' => false,
];

21
config/autoload.php Normal file
View File

@@ -0,0 +1,21 @@
<?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 [
'files' => [
base_path() . '/app/functions.php',
base_path() . '/support/Request.php',
base_path() . '/support/Response.php',
]
];

18
config/bootstrap.php Normal file
View File

@@ -0,0 +1,18 @@
<?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 [
support\bootstrap\Database::class,
support\bootstrap\Session::class,
];

15
config/container.php Normal file
View File

@@ -0,0 +1,15 @@
<?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 new Webman\Container;

23
config/database.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
return [
'default' => 'mysql',
'connections' => [
'mysql' => [
'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') ?: '',
'unix_socket' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
'options' => [
\PDO::ATTR_TIMEOUT => 3
]
],
],
];

15
config/dependence.php Normal file
View File

@@ -0,0 +1,15 @@
<?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 [];

4
config/exception.php Normal file
View File

@@ -0,0 +1,4 @@
<?php
return [
'' => support\ExceptionHandler::class,
];

32
config/log.php Normal file
View 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/webman.log',
7, //$maxFiles
Monolog\Logger::DEBUG,
],
'formatter' => [
'class' => Monolog\Formatter\LineFormatter::class,
'constructor' => [null, 'Y-m-d H:i:s', true],
],
]
],
],
];

19
config/middleware.php Normal file
View File

@@ -0,0 +1,19 @@
<?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 [
'@' => [
app\middleware\Cors::class,
],
];

View File

@@ -0,0 +1,4 @@
<?php
return [
'enable' => true,
];

View File

@@ -0,0 +1,7 @@
<?php
use Webman\RedisQueue\Command\MakeConsumerCommand;
return [
MakeConsumerCommand::class
];

View 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],
],
]
],
]
];

View File

@@ -0,0 +1,11 @@
<?php
return [
'consumer' => [
'handler' => Webman\RedisQueue\Process\Consumer::class,
'count' => 8, // 可以设置多进程同时消费
'constructor' => [
// 消费者类目录
'consumer_dir' => app_path() . '/queue/redis'
]
]
];

View File

@@ -0,0 +1,21 @@
<?php
return [
'default' => [
'host' => 'redis://127.0.0.1:6379',
'options' => [
'auth' => null,
'db' => 0,
'prefix' => '',
'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,
]
],
];

62
config/process.php Normal file
View File

@@ -0,0 +1,62 @@
<?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
*/
use support\Log;
use support\Request;
use app\process\Http;
global $argv;
return [
'webman' => [
'handler' => Http::class,
'listen' => 'http://0.0.0.0:8787',
'count' => 4,
'user' => '',
'group' => '',
'reusePort' => false,
'eventLoop' => '',
'context' => [],
'constructor' => [
'requestClass' => Request::class,
'logger' => Log::channel('default'),
'appPath' => app_path(),
'publicPath' => public_path()
]
],
// File update detection and automatic reload
'monitor' => [
'handler' => app\process\Monitor::class,
'reloadable' => false,
'constructor' => [
// Monitor these directories
'monitorDir' => array_merge([
app_path(),
config_path(),
base_path() . '/process',
base_path() . '/support',
base_path() . '/resource',
base_path() . '/.env',
], glob(base_path() . '/plugin/*/app'), glob(base_path() . '/plugin/*/config'), glob(base_path() . '/plugin/*/api')),
// Files with these suffixes will be monitored
'monitorExtensions' => [
'php', 'html', 'htm', 'env'
],
'options' => [
'enable_file_monitor' => !in_array('-d', $argv) && DIRECTORY_SEPARATOR === '/',
'enable_memory_monitor' => DIRECTORY_SEPARATOR === '/',
]
]
]
];

109
config/route.php Normal file
View File

@@ -0,0 +1,109 @@
<?php
use Webman\Route;
Route::group('/api', function () {
Route::post('/auth/login', [app\api\controller\AuthController::class, 'login'])->name('api.auth.login');
Route::get('/wechat/app_list', [app\api\controller\WechatAuthController::class, 'appList'])->name('api.wechat.app_list');
Route::post('/wechat/mini_login', [app\api\controller\WechatAuthController::class, 'miniLogin'])->name('api.wechat.mini_login');
Route::post('/wechat/h5_login', [app\api\controller\WechatAuthController::class, 'h5Login'])->name('api.wechat.h5_login');
Route::get('/wechat/h5_authorize_url', [app\api\controller\WechatAuthController::class, 'h5AuthorizeUrl'])->name('api.wechat.h5_authorize_url');
// 公开验证防伪接口
Route::get('/report/verify', [app\api\controller\ReportController::class, 'verify'])->name('api.report.verify');
Route::post('/pay/wechat/notify', [app\api\controller\PayController::class, 'wechatNotify'])->name('api.pay.wechat.notify');
Route::group('', function () {
Route::get('/auth/me', [app\api\controller\AuthController::class, 'me'])->name('api.auth.me');
Route::post('/auth/logout', [app\api\controller\AuthController::class, 'logout'])->name('api.auth.logout');
Route::post('/upload/image', [app\api\controller\UploadController::class, 'image'])->name('api.upload.image');
Route::group('/order', function () {
Route::post('/create', [app\api\controller\OrderController::class, 'create']);
Route::post('/pay', [app\api\controller\OrderController::class, 'pay']);
Route::post('/ship', [app\api\controller\OrderController::class, 'ship']);
Route::get('/list', [app\api\controller\OrderController::class, 'list']);
Route::get('/detail/{id}', [app\api\controller\OrderController::class, 'detail']);
});
Route::group('/report', function () {
Route::get('/detail', [app\api\controller\ReportController::class, 'detail']);
});
Route::group('/user', function () {
Route::get('/stat', [app\api\controller\UserController::class, 'stat']);
Route::post('/update_info', [app\api\controller\UserController::class, 'updateInfo']);
});
})->middleware(app\api\middleware\AuthMiddleware::class);
});
Route::group('/admin', function () {
Route::post('/auth/login', [app\admin\controller\AuthController::class, 'login'])->name('admin.auth.login');
Route::get('/auth/me', [app\admin\controller\AuthController::class, 'me'])
->middleware(app\admin\middleware\AuthMiddleware::class)
->name('admin.auth.me');
Route::post('/auth/logout', [app\admin\controller\AuthController::class, 'logout'])
->middleware(app\admin\middleware\AuthMiddleware::class)
->name('admin.auth.logout');
Route::post('/upload/image', [app\admin\controller\UploadController::class, 'image'])->name('admin.upload.image');
Route::group('', function () {
// Dashboard
Route::get('/dashboard/stat', [app\admin\controller\DashboardController::class, 'stat'])->name('admin.dashboard.stat');
// Order
Route::get('/order/list', [app\admin\controller\OrderController::class, 'list'])->name('admin.order.list');
Route::get('/order/detail', [app\admin\controller\OrderController::class, 'detail'])->name('admin.order.detail');
Route::post('/order/receive', [app\admin\controller\OrderController::class, 'receive'])->name('admin.order.receive');
Route::post('/order/return_ship', [app\admin\controller\OrderController::class, 'returnShip'])->name('admin.order.return_ship');
// Report
Route::get('/report/list', [app\admin\controller\ReportController::class, 'list'])->name('admin.report.list');
Route::get('/report/detail', [app\admin\controller\ReportController::class, 'detail'])->name('admin.report.detail');
Route::post('/report/create', [app\admin\controller\ReportController::class, 'create'])->name('admin.report.create');
// Admin User
Route::get('/admin_user/list', [app\admin\controller\AdminUserController::class, 'list'])->name('admin.admin_user.list');
Route::post('/admin_user/create', [app\admin\controller\AdminUserController::class, 'create'])->name('admin.admin_user.create');
Route::post('/admin_user/update', [app\admin\controller\AdminUserController::class, 'update'])->name('admin.admin_user.update');
Route::post('/admin_user/delete', [app\admin\controller\AdminUserController::class, 'delete'])->name('admin.admin_user.delete');
// C-User
Route::get('/user/list', [app\admin\controller\UserController::class, 'list'])->name('admin.user.list');
Route::post('/user/update_status', [app\admin\controller\UserController::class, 'updateStatus'])->name('admin.user.update_status');
// Role
Route::get('/role/list', [app\admin\controller\RoleController::class, 'list'])->name('admin.role.list');
Route::get('/role/all', [app\admin\controller\RoleController::class, 'all'])->name('admin.role.all');
Route::post('/role/create', [app\admin\controller\RoleController::class, 'create'])->name('admin.role.create');
Route::post('/role/update', [app\admin\controller\RoleController::class, 'update'])->name('admin.role.update');
Route::post('/role/delete', [app\admin\controller\RoleController::class, 'delete'])->name('admin.role.delete');
// Permission
Route::get('/permission/list', [app\admin\controller\PermissionController::class, 'list'])->name('admin.permission.list');
Route::post('/permission/create', [app\admin\controller\PermissionController::class, 'create'])->name('admin.permission.create');
Route::post('/permission/update', [app\admin\controller\PermissionController::class, 'update'])->name('admin.permission.update');
Route::post('/permission/delete', [app\admin\controller\PermissionController::class, 'delete'])->name('admin.permission.delete');
// Wechat Merchant
Route::get('/wechat_merchant/list', [app\admin\controller\WechatMerchantController::class, 'list'])->name('admin.wechat_merchant.list');
Route::post('/wechat_merchant/create', [app\admin\controller\WechatMerchantController::class, 'create'])->name('admin.wechat_merchant.create');
Route::post('/wechat_merchant/update', [app\admin\controller\WechatMerchantController::class, 'update'])->name('admin.wechat_merchant.update');
Route::post('/wechat_merchant/delete', [app\admin\controller\WechatMerchantController::class, 'delete'])->name('admin.wechat_merchant.delete');
Route::post('/wechat_merchant/upload_apiclient_cert', [app\admin\controller\WechatMerchantController::class, 'uploadApiclientCert'])->name('admin.wechat_merchant.upload_apiclient_cert');
Route::post('/wechat_merchant/upload_apiclient_key', [app\admin\controller\WechatMerchantController::class, 'uploadApiclientKey'])->name('admin.wechat_merchant.upload_apiclient_key');
Route::post('/wechat_merchant/upload_api_v3_key', [app\admin\controller\WechatMerchantController::class, 'uploadApiV3Key'])->name('admin.wechat_merchant.upload_api_v3_key');
// Wechat App
Route::get('/wechat_app/list', [app\admin\controller\WechatAppController::class, 'list'])->name('admin.wechat_app.list');
Route::post('/wechat_app/create', [app\admin\controller\WechatAppController::class, 'create'])->name('admin.wechat_app.create');
Route::post('/wechat_app/update', [app\admin\controller\WechatAppController::class, 'update'])->name('admin.wechat_app.update');
Route::post('/wechat_app/delete', [app\admin\controller\WechatAppController::class, 'delete'])->name('admin.wechat_app.delete');
})->middleware([
app\admin\middleware\AuthMiddleware::class,
app\admin\middleware\PermissionMiddleware::class,
]);
});

23
config/server.php Normal file
View File

@@ -0,0 +1,23 @@
<?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 [
'event_loop' => '',
'stop_timeout' => 2,
'pid_file' => runtime_path() . '/webman.pid',
'status_file' => runtime_path() . '/webman.status',
'stdout_file' => runtime_path() . '/logs/stdout.log',
'log_file' => runtime_path() . '/logs/workerman.log',
'max_package_size' => 10 * 1024 * 1024
];

65
config/session.php Normal file
View File

@@ -0,0 +1,65 @@
<?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
*/
use Webman\Session\FileSessionHandler;
use Webman\Session\RedisSessionHandler;
use Webman\Session\RedisClusterSessionHandler;
return [
'type' => 'file', // or redis or redis_cluster
'handler' => FileSessionHandler::class,
'config' => [
'file' => [
'save_path' => runtime_path() . '/sessions',
],
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
'auth' => '',
'timeout' => 2,
'database' => '',
'prefix' => 'redis_session_',
],
'redis_cluster' => [
'host' => ['127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7001'],
'timeout' => 2,
'auth' => '',
'prefix' => 'redis_session_',
]
],
'session_name' => 'PHPSID',
'auto_update_timestamp' => false,
'lifetime' => 7*24*60*60,
'cookie_lifetime' => 365*24*60*60,
'cookie_path' => '/',
'domain' => '',
'http_only' => true,
'secure' => false,
'same_site' => '',
'gc_probability' => [1, 1000],
];

23
config/static.php Normal file
View File

@@ -0,0 +1,23 @@
<?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
*/
/**
* Static file settings
*/
return [
'enable' => true,
'middleware' => [ // Static file Middleware
//app\middleware\StaticFile::class,
],
];

25
config/translation.php Normal file
View File

@@ -0,0 +1,25 @@
<?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
*/
/**
* Multilingual configuration
*/
return [
// Default language
'locale' => 'zh_CN',
// Fallback language
'fallback_locale' => ['zh_CN', 'en'],
// Folder where language files are stored
'path' => base_path() . '/resource/translations',
];

22
config/view.php Normal file
View File

@@ -0,0 +1,22 @@
<?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
*/
use support\view\Raw;
use support\view\Twig;
use support\view\Blade;
use support\view\ThinkPHP;
return [
'handler' => Raw::class
];