【发布时间】:2019-07-25 20:43:16
【问题描述】:
我正在设置 slim 路由器 v4,我希望能够使用路由中的 placeholder 动态调用控制器方法。
即当向“example.com/users/{action}”发出请求时,路由器会自动从 Users.php 控制器调用该方法,而无需我手动指定路由。
基本上,当它们都在 /user 路由下时,我试图避免手动添加超过 100 个组->get(...)。
namespace core\router;
use Slim\Interfaces\RouteCollectorProxyInterface;
use app\controllers\users;
$app->group('/user', function(RouteCollectorProxyInterface $group){
$group->get('/get-name', '\Users:name')
$group->get('/get-personality', '\Users:personality');
});
here 提供了进一步的解释,但我不知道该怎么做。
【问题讨论】:
-
您是否尝试先询问here?
标签: php url-routing slim