php - Slim framework url as file path -
i'm new using slim , trying create simple file hosting site. i'm trying set current directory via url using $app->get()
. there way can have url such as: site.com/panel/documents/text/word/etc
after panel
interpreted current path? have code:
$app->get('/panel/{path}', function ($request, $response) { $path = $request->getattribute('path'); return $path; });
the issue i'm able return path
when 1 path set, i.e. /panel/documents
returns documents
. if such /panel/documents/text
return not found error. great. thanks!
assuming using latest slim v3, can use placeholders achieve goal per documentation: http://www.slimframework.com/docs/objects/router.html#route-placeholders
look unlimited optional params
$app->get('/news[/{params:.*}]', function ($request, $response, $args) { $params = explode('/', $request->getattribute('params')); // $params array of optional segments });
in case be:
$app->get('/panel/{path:.*}', function ($request, $response) { $path = $request->getattribute('path'); return $path; });
Comments
Post a Comment