drwkqwa82140 2018-06-29 06:14 采纳率: 0%
浏览 41

Cakephp插件前缀不起作用

I'm creating a Cakephp(3.5.14) plugin, it is working fine with the below given routes 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);

as per the documentation this I added in project src/config/routes.php

$routes->scope('/backend', function ($routes) {
        $routes->loadPlugin('Timesheet');
    });

BUt somehow, it's not working.

My URL: www.xxx.com/backend/timesheets

Error: BackendController could not be found.

In the case you tried to access a plugin controller make sure you added it to your composer file or you use the autoload option for the plugin.

Error: Create the class BackendController below in file: src\Controller\BackendController.php

use App\Controller\AppController;

class BackendController extends AppController {

}

Stack Trace:

⟩ 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

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • douzao9845 2018-06-29 09:43
    关注

    Check the other routes that are connected in your application, there's most likely a route connected earlier that catches the request, probably one that looks for something like /:controller/:action (either explicitly, or as fallback routes), hence it uses the backend part as the controller.

    You can easily get a list of all connected routes via the routes shell:

    bin/cake routes
    
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向