CakePHP 3:存在的路由缺少路由错误
CakePHP 3.0
对于存在的路由,我收到“Missing Route”错误。
这是我的路线:
#my admin routes...
Router::prefix('admin', function($routes) {
$routes->connect('/', ['controller'=>'Screens', 'action'=>'index']);
$routes->connect('/screens', ['controller'=>'Screens', 'action'=>'index']);
$routes->connect('/screens/index', ['controller'=>'Screens', 'action'=>'index']);
//$routes->fallbacks('InflectedRoute');
});
Router::scope('/', function ($routes) {
$routes->connect('/login', ['controller' => 'Pages', 'action' => 'display', 'login']);
$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
$routes->fallbacks('InflectedRoute');
});
Plugin::routes();
基本上我只是将最上面的部分(用于管理路由)添加到默认路由中。
当我访问/admin/screens/index
我看到以下错误:
注意错误消息说:
错误:匹配“array('action'=>'add','prefix'=>'admin','plugin'=> NULL,'controller'=>'Screens','_ext'=> NULL的路由“找不到。
...这很奇怪,因为我不想访问add
动作。 下面打印的参数看起来是正确的。
到底是怎么回事?
这对我使用前缀管理员的工作: -
Router::prefix('admin', function ($routes) {
// Because you are in the admin scope,
// you do not need to include the /admin prefix
// or the admin route element.
$routes->connect('/', ['controller' => 'Users', 'action' => 'index']);
$routes->extensions(['json', 'xml']);
// All routes here will be prefixed with `/admin`
$routes->connect('/admin', ['controller' => 'Order', 'action' => 'index']);
// And have the prefix => admin route element added.
$routes->fallbacks(DashedRoute::class);
});
链接地址: http://www.djcxy.com/p/58831.html
上一篇: CakePHP 3: Missing route error for route that exists
下一篇: How to retrieve information when linking models through a table in CakePHP 3.0?