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

請(qǐng)問一個(gè)多級(jí)目錄下路由的問題

changup

webman訪問路徑

http://server.com/app/b/c/index/hello

期望的訪問路徑

http://server.com/app/b.c.index/hello
這個(gè)怎么配置路由啊,謝謝大佬

1008 3 0
3個(gè)回答

taozywu

目錄結(jié)構(gòu)如下:

app
 --test
    --test2
        --controller
            Index.php
<?php

namespace app\test\test2\controller;

use support\Request;

class Index
{

    public function hello(Request $request)
    {
        return response('ok');
    }
}

路由配置:

config/route.php
Route::any('/app/test.test2.index/hello', [app\test\test2\controller\Index::class, 'hello']);
  • changup 2022-09-16

    謝謝大佬,有沒有通用的處理辦法,不用挨個(gè)寫這么多

taozywu
Route::any('/app/{name1}/{name2}', function ($request, $name1 = null, $name2 = null) {
    // @todo需要優(yōu)化
    list($app1, $app2, $controller) = explode(".", $name1);
    $class_name = "app\\{$app1}\\{$app2}\\controller\\" . ucwords($controller).config("app.controller_suffix", "");
    $class = new $class_name;
    return call_user_func([$class, $name2], $request);
 });

===
僅做參考

  • changup 2022-10-10

    謝謝大佬,我一會(huì)試試

taozywu

使用nginx代理的話,可以使用rewrite

upstream webman {
    server 127.0.0.1:8787;
    keepalive 10240;
}

location / {
    rewrite ^/app/\.(.*)\.(.*)\.(.*)/(.*)$ $1/$2/$3/$4 break;
    proxy_pass   http://webman;
}

===
僅做參考

  • changup 2022-10-10

    謝謝大佬,我一會(huì)試試

年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??