我正在研究Slim 3上的(非常轻量级)CMS,用于我正在进行的一些项目。我正在努力路由。也许这里的某个人可以把我推向正确的方向。
管理员可以在后端添加新的前端页面。如果添加页面,则会自动创建一个slug。有几页(如索引页面)无法删除或编辑(更改slug)
现在我不知道如何设置路由。
我想要的例子:
www.example.com/
www.example.com/contact.html www.example.com/some-page.html
我能够建立一个通配符路由,但为了让事情变得更有趣,我也有一些后端路由:
www.example.com/backend/
www.example.com/backend/dashboard/
$app->get('/[{path:.*}]', function($request, $response, $path = null) { return $response->write($path ? 'subroute' : 'index'); });
$app->group('', function () {
$this->get('/backend/dashboard.html', 'BackendDashboardController:index')->setName('backend');
});
一旦我实现这些,我得到以下错误:
Static route "/backend/dashboard.html" is shadowed by previously defined variable route "/(.*)" for method "GET"
每个提示都会非常感激。
如果您为“/ backend”路径创建组,它应该可以工作。
$app->group('/backend', function () {
$this->get('/dashboard.html', 'BackendDashboardController:index')->setName('backend');
});
$app->get('/[{path:.*}]', function($request, $response, $path = null) { return $response->write($path ? 'subroute' : 'index'); });