国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

獲取當(dāng)前請(qǐng)求路由信息,$route->getPath()報(bào)錯(cuò)

fuxu
use Webman\Route;

Route::group('/blog', function () {
    Route::any('/create', [app\controller\UserController::class, 'hello'])->name('11222');
});

 public function hello(Request $request)
    {
        $route = $request->route;
        var_export($route->getPath());
        var_export('ok');
        // return response('name ' . $route->getName());
    }

Error: Call to undefined method Webman\Route\Route::getPath()

1466 7 0
7個(gè)回答

nitron
  • fuxu 2022-12-05

    $request->path();是可以獲取到

    $route = $request->route;
    $route->getMethods(); 這個(gè)是報(bào)錯(cuò)
    $route->getName();這個(gè)是正常

  • powerbowen 2022-12-05

    $request->method();

  • fuxu 2022-12-05

    $route是不行嗎?

  • powerbowen 2022-12-05

    $route->getMethods(); 得到的是這東西 ["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"] ,而且你要走路由管理的路由,不然$route是null

  • fuxu 2022-12-05

    $route不是null,上面我說(shuō)錯(cuò)了,是$route->getPath()報(bào)錯(cuò)

  • powerbowen 2022-12-05

    走路由管理配置的沒(méi)有任何問(wèn)題,你說(shuō)$route不是null,打印截圖貼出來(lái)。
    Error: Call to undefined method Webman\Route\Route::getPath() 報(bào)錯(cuò)這這里呢,你別騙我,我讀書(shū)少

  • fuxu 2022-12-05

    看打印截圖

powerbowen

OK的
截圖
截圖
截圖
截圖

Route::any('/api', [\app\controller\ApiController::class, 'index'])->name('11222');

    public function index(Request $request): Response
    {
        $route = $request->route;
        var_export($route);
        var_export($route->getPath());
        return json($route->getPath());
    }
  • fuxu 2022-12-05

    我也不明白,只有$route->getPath()報(bào)錯(cuò)

  • powerbowen 2022-12-05

    你代碼發(fā)我郵箱我瞧瞧 270723814@qq.com

  • fuxu 2022-12-05

    我是剛學(xué)習(xí),就按照文檔做的,就這一段代碼
    $route = $request->route;
    var_dump($route->getPath());

  • six 2022-12-05

    執(zhí)行composer info 看下版本 webman-framework 版本

  • fuxu 2022-12-05

    版本是"workerman/webman-framework": "^1.4.3"

  • six 2022-12-05

    打開(kāi)Webman\Route\Route 這個(gè)類(lèi),看下getPath方法是否存在。

  • fuxu 2022-12-05

    沒(méi)有g(shù)etPath

fuxu

截圖截圖

  • 暫無(wú)評(píng)論
fuxu

我在win上面又試了試,沒(méi)有問(wèn)題
在docker出現(xiàn)了問(wèn)題

powerbowen

截圖

  • 暫無(wú)評(píng)論
fuxu

截圖

  • 暫無(wú)評(píng)論
小W

看了一下webman-framework源碼,getPath沒(méi)問(wèn)題,應(yīng)該是你改動(dòng)了源碼,重新install試試

  • 暫無(wú)評(píng)論
年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??