Debugkit not showing due to missing route

I’m not far into my first v4.x app. I got the Authentication plugin running with the AuthenticationMiddleware and noticed the Debugkit was not at the bottom of the page.

I used the ‘bigger-hammer’ fix to make sure…

Configure::write('DebugKit.ignoreAuthorization', true);
Configure::write('DebugKit.forceEnable', true);
$this->addPlugin('DebugKit');

This did yield a red ‘something’ in the lower right corner of the screen. I used css to pry that little thing open and found an error page rendering with this error:

Since I haven’t done anything unusual at this point it seems like the default routing should still be viable? I only have one baked controller.

bin/cake routes reports:

Indeed, the named route is missing. Admittedly I don’t have a proper working knowledge of routing, but again, I’m not off the reservation at this point.

What am I looking at here and how do I proceed?

Update:

When I add a new route at the end of the default setup (after the fallback):

$builder->fallbacks();
$builder->connect('/:controller/:action/*', ['plugin' => 'DebugKit']);

Things work. But my confusion does not end. When I look at the Routes table in the DebugKit panel:

As I said, I’m not solid on routes yet but… The final route seems to be the one that got me up an running. But its name debugkit._controller:_action is suggesting to me that it will lead to a debugkit plugin controller?

I am operational at this point but I’d like to understand what’s going on rather than live with this opaque solution. It feels like I’m fixing my Dad’s Studebaker with a bit of tech picked up from a field in Roswell.

Remove your custom route and try enabling bootstrap, routes and middleware to the loadPlugin config.

$this->addPlugin('DebugKit', ['bootstrap' => true, 'routes' => true, 'middleware' => true);

may be the error is a bit missleading and your debugkit is broken. I struggled some days ago as well with similar issues and decided to do a fresh update of the debugkit using

composer require --dev cakephp/debug_kit "~4.0"

no errors anymore.

@coreytaylor That did the trick, thanks

Hello @dreamingmind !! Same problem here, after Authentication plugin installation.l
Where did you apply the @coreytaylor solution?

Thanks! :slight_smile:

Same problems here.

My problem is system could not load toolbar.js properly after add authentication plugin.

It works back when I remove its middleware “->add(new AuthenticationMiddleware($this))” in /src/Application.php

http://localhost:8765/debug-kit/toolbar/6945accb-0b9a-4a7d-a406-a281d27d3c12 404 (Not Found)

I fixed this in src/Application.php

Stripped down, here is what my fix looked like

<?php
declare(strict_types=1);

namespace App;

class Application extends BaseApplication

   public function bootstrap() : void 
   {

      // code here
   
      if (Configure::read('debug')) {
         $this->addPlugin('DebugKit', ['bootstrap' => true, 'routes' => true, 'middleware' => true]);
      }

      // more code here

   }

}

Problem fixed, the solution is:
At /src/Application.php, we need add a function:
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface for Authentication.

I did:
Router::url([‘controller’ => ‘Users’, ‘action’ => ‘login’, ‘plugin’ => null, ‘prefix’ => null])

It was:
Router::url([‘controller’ => ‘Users’, ‘action’ => ‘login’])

Answser is from: DebugKit not loading because of missing login route · Issue #345 · cakephp/authentication · GitHub

1 Like