http://server.com/app/b/c/index/hello
http://server.com/app/b.c.index/hello
這個(gè)怎么配置路由啊,謝謝大佬
目錄結(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']);
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);
});
===
僅做參考