When defining prefixes, you can nest multiple prefixes if necessary:
As example is shown:
$routes->prefix('Manager', function (RouteBuilder $routes) {
$routes->prefix('Admin', function (RouteBuilder $routes) {
$routes->connect('/{controller}/{action}');
});
});
In my case this had to be:
$routes->prefix('Backend', function (RouteBuilder $routes) {
$routes->prefix('Admin', function (RouteBuilder $routes) {
//$routes->connect('/{controller}/{action}'); //=> errormessage: BackendController could not be found.
$routes->fallbacks(DashedRoute::class); //works
});
});
If I use (inside of $routes->prefix…)":
$routes->connect('/{controller}/{action}');
I get the error “BackendController could not be found.”
$routes->prefix('Customer', function (RouteBuilder $routes) {
$routes->prefix('Admin', function (RouteBuilder $routes) {
$routes->connect('/{controller}/{action}'); //=> errormessage: ...Controller could not be found.
//$routes->fallbacks(DashedRoute::class); //works
});
});
I mostly just use explicit and fallback routes, not much in the way of parameterized ones like this, so take this with a grain of salt. But it seems to me that the URL you’re trying to access won’t match the route you’ve specified here because there is no action parameter.
You’re both right, and thank you for the advice. I’m still having a bit of trouble with the routing at the moment, but that’s due to my poor English skills.