I'm trying to setting up symfony/routing component on my project..
Things go well but when I define prefix for routes, it throw route not found exception for root path of this prefix.
For example, let assume I have bunch of admin routes. Instead of defining "admin" keyword on each route I made a prefix route all of those. So my dashboard path turned into "/"
from "/admin"
. And now it throws route not found error..
When I checked the route collections. Dashboard path seems as "/admin/"
. And its not matching with REQUEST_URI
Am I setting up the component poorly or there are some cautions that I need to do ?
Here is part of RouteProvider
foreach (scanDirectory(ROOT_PATH . "/routes") as $file) {
$subCollection = new RouteCollection();
$filepath = ROOT_PATH . "/routes/" . $file;
$routes = Yaml::parseFile($filepath);
$prefix = "api";
if (array_key_exists("prefix", $routes)){
$prefix = $routes["prefix"];
unset($routes["prefix"]);
}
foreach ($routes as $name => $route) {
$parameters = (new RouteParser($route))->parse();
$subCollection->add(
$name,
new Route(...$parameters)
);
}
$subCollection->addPrefix($prefix);
$subCollection->addOptions([
"trailing_slash_on_root" => false
]);
$collection->addCollection($subCollection);
}