我有一个名为PanelAdmin的插件。它有Controller UsersController.php
,里面有定义的不同动作。
我通过这段代码调用了插件中的默认控制器
$routes->connect('/PanelAdmin', ['plugin' => 'PanelAdmin','controller' => 'default','action' => 'index']);
但如果我点击此网址,则无法调用其他控制器:
http://localhost/multi_shopping/PanelAdmin/Users/
我想要清楚的是,我必须为routes.php中的所有控制器操作定义路由。请解决我的问题。感谢
答案 0 :(得分:0)
在您的插件routes.php
中,确保您正在设置后备路线。
<强> routes.php文件强>
<?php
use Cake\Routing\Route\DashedRoute;
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;
Router::plugin(
'PanelAdmin',
['path' => '/PanelAdmin'],
function (RouteBuilder $routes) {
$routes->fallbacks(DashedRoute::class);
}
);
来自DashedRoute类:
/**
* This route class will transparently inflect the controller, action and plugin
* routing parameters, so that requesting `/my-plugin/my-controller/my-action`
* is parsed as `['plugin' => 'MyPlugin', 'controller' => 'MyController', 'action' => 'myAction']`
*/