CakePHP 3: Missing route error for route that exists
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', 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();
Basically I just added the top section (for admin routing) to the default routes that come out of the box.
When I visit /admin/screens/index
I see the following error:
Notice the error message says:
Error: A route matching "array ( 'action' => 'add', 'prefix' => 'admin', 'plugin' => NULL, 'controller' => 'Screens', '_ext' => NULL, )" could not be found.
...which is strange because I am not trying to access the add
action. The params printed below look correct.
What is going on?
这对我使用前缀管理员的工作: -
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/58832.html
上一篇: Cakephp管理路由阻止常规用户