CakePHP 3: Missing route error for route that exists

后端 未结 2 808
离开以前
离开以前 2020-12-16 19:28

CakePHP 3.0

I\'m getting a \"Missing Route\" error for a route that exists.

Here are my routes:

#my admin routes...
Router::prefix(\'admin\'         


        
2条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 19:45

    Take a closer look at the stacktrace, the error dosn't occour in the dispatching process, which you seem to think, it is being triggered in your view template, where you are probably trying to create a link to the add action, and reverse-routing cannot find a matching route, hence the error.

    The solution should be obvious, connect the necessary routes, being it explicit ones like

    $routes->connect('/screens/add', ['controller' => 'Screens', 'action' => 'add']);
    

    catch-all ones

    $routes->connect('/screens/:action', ['controller' => 'Screens']);
    

    or simply the fallback ones that catch everything

    $routes->fallbacks('InflectedRoute');
    

提交回复
热议问题