Weird Missing Route message for a route that actually exists


#1

My routing.php contains such string:
$routes->connect(’/product_detail/’, [‘controller’ => ‘pages’, ‘action’ => ‘productDetail’]);

But I am getting such message:
Error: A route matching “product_detail” could not be found.

I see debug info and in the list of connected routes I see:
/product_detail [ ‘controller’ = ‘pages’, ‘action’ = ‘productDetail’, ‘plugin’ = null ] [ ‘_ext’ = [], ‘routeClass’ = ‘Cake\Routing\Route\DashedRoute’ ]

It was working fine and this error appeared only when I upgraded my CakePHP from 3.3 to 3.6.


#2

Try to remove the trailing slash. What does happen?
Like this:
$routes->connect(’/product_detail’, [‘controller’ => ‘pages’, ‘action’ => ‘productDetail’]);


#3

I already tried, the same message


#4

I noticed that something has changed from cakePHP 3.4 (3.3.16 works fine), but can not understand what exactly changed


#5

In 3.x controller names in URL/route arrays are supposed to be in CamelCased form. So 'controller' => 'Pages' not 'controller' => 'pages'.

Also if you prefer using underscore instead of dash in URLs then you using be used InflectedRoute instead of DashedRoute class.


#6

also tried, no result…


#7

Maybe, problem with underscore ‘_’ ?