【已解决】webman 路由 /admin//login 控制台报错 Worker [xxxx] process terminated with ERROR: E_COMPILE_ERROR

lsmir2

问题描述

起因是调试接口在 我在请求地址控制器后面多打了一个斜杆
127.0.0.1:8787/admin//login/refreshToken

程序代码

config/route.php

<?php
use Webman\Route;
Route::fallback(function () {
    // 处理跨域 options 请求
    response()->withHeaders([
        'Access-Control-Allow-Credentials' => 'true',
        'Access-Control-Allow-Origin' => request()->header('Origin', '*'),
        'Access-Control-Allow-Methods' => '*',
        'Access-Control-Allow-Headers' => '*',
    ]);
    if (request()->method() == 'OPTIONS') {
        return response();
    }
    return json_encode(['code' => 404, 'msg' => 'Not Found']);
//    throw new \Tinywan\ExceptionHandler\Exception\RouteNotFoundException();
});

//// 引用 routes 中的路由文件
foreach (glob(BASE_PATH . "/routes/*.php") as $filename)
{
    require_once $filename;
}

# 关闭自动路由
Route::disableDefaultRoute();
<?php
use Webman\Route;
Route::group('/admin', function () {
    Route::post('/login', [app\admin\controller\LoginController::class, 'login'], '/login', true);
    Route::post('/login/refreshToken', [app\admin\controller\LoginController::class, 'refreshToken'], '/refreshToken', true);
}, 'admin', true);

报错信息

Fatal error: Cannot declare class app\admin\controller\LoginController, because the name is already in use in /webman/app/admin/controller/loginController.php on line 11
Worker[14634] process terminated with ERROR: E_COMPILE_ERROR "Cannot declare class app\admin\controller\LoginController, because the name is already in use in /webman/app/admin/controller/loginController.php on line 11"
worker[webman:14634] exit with status 65280

操作系统及workerman/webman等框架组件具体版本

mac os 12.7.5 (21H1222)
Webman-framework v1.5.17

381 1 0
1个回答

walkor 打赏

升级webman-framework
composer require workerman/webman-framework ^v1.5.18

  • lsmir2 2024-05-26

    更了 不报错了.现在 2斜杆 提示 404 我不太明白大佬的意图 $path = str_replace(['-', '//'], ['', '/'], $path); 按我理解 //替换了单斜杆不应该是404错误而是正常显示 ,

  • walkor 2024-05-26

    我这测试正常,没有404

×
🔝