我正在创建一个Cakephp(3.5.14)插件,它在以下给定的路由下工作正常 plugins / timesheet / config / routes.php
Router::plugin(
'Timesheet', ['path' => '/timesheets'], function (RouteBuilder $routes) {
$routes->setExtensions(['json']);
$routes->connect('/', ['controller' => 'Timesheets', 'action' => 'index']);
$routes->connect('/edit', ['controller' => 'Timesheets', 'action' => 'edit']);
$routes->connect('/add', ['controller' => 'Timesheets', 'action' => 'add']);
$routes->fallbacks(DashedRoute::class);
根据我在其中添加的文档this 项目src / config / routes.php
$routes->scope('/backend', function ($routes) {
$routes->loadPlugin('Timesheet');
});
以某种方式发射,它不起作用。
我的网址:www.xxx.com/backend/timesheets
错误:找不到BackendController。
如果您尝试访问插件控制器,请确保将其添加到作曲家文件中,或者对插件使用自动加载选项。
错误:在文件src \ Controller \ BackendController.php
中创建下面的类BackendController。
使用App \ Controller \ AppController;
Class BackendController扩展了AppController {
}
堆栈跟踪:
⟩ Cake\Http\ControllerFactory->missingController
CORE\src\Http\ControllerFactory.php, line 38
⟩ Cake\Http\ControllerFactory->create
CORE\src\Http\ActionDispatcher.php, line 90
⟩ Cake\Http\ActionDispatcher->dispatch
CORE\src\Http\BaseApplication.php, line 108
⟩ Cake\Http\BaseApplication->__invoke
CORE\src\Http\Runner.php, line 65
⟩ Cake\Http\Runner->__invoke
CORE\src\Routing\Middleware\RoutingMiddleware.php, line 104
⟩ Cake\Routing\Middleware\RoutingMiddleware->__invoke
CORE\src\Http\Runner.php, line 65
⟩ Cake\Http\Runner->__invoke
CORE\src\Routing\Middleware\AssetMiddleware.php, line 88
⟩ Cake\Routing\Middleware\AssetMiddleware->__invoke
CORE\src\Http\Runner.php, line 65
⟩ Cake\Http\Runner->__invoke
CORE\src\Error\Middleware\ErrorHandlerMiddleware.php, line 98
⟩ Cake\Error\Middleware\ErrorHandlerMiddleware->__invoke
CORE\src\Http\Runner.php, line 65
⟩ Cake\Http\Runner->__invoke
ROOT\vendor\cakephp\debug_kit\src\Middleware\DebugKitMiddleware.php, line 52
⟩ DebugKit\Middleware\DebugKitMiddleware->__invoke
CORE\src\Http\Runner.php, line 65
⟩ Cake\Http\Runner->__invoke
CORE\src\Http\Runner.php, line 51
⟩ Cake\Http\Runner->run
CORE\src\Http\Server.php, line 81
⟩ Cake\Http\Server->run
ROOT\webroot\index.php, line 40
谢谢。
答案 0 :(得分:0)
检查应用程序中连接的其他路由,很可能是连接较早的路由会捕获请求,可能是寻找类似/:controller/:action
之类的路由(无论是显式路由还是后备路由),因此使用backend
部分作为控制器。
您可以通过routes shell轻松获得所有连接路线的列表:
bin/cake routes