[Solved]Named route not found


#1

Hello,

Using CakePHP 3.5.17 and I want to use a custom named route.

I defined my route like this : Router::connect('/:username',['controller' => 'Tweet', 'action' => 'index'],['username' => '[a-z0-9-_]+', 'pass' =>['username']],['_name' => 'profil']);

And i’m trying to it like this :

http://localhost/website/test

But CakePHP 3 say " Missing Route Cake\Routing\Exception\MissingRouteException Error: A route matching “profil” could not be found."

Can you help me


#2

you have too many parameters, connect have only 3 and you gave 4, the _name should be in 3rd array

[
    'username' => '[a-z0-9-_]+',
    'pass' => ['username'],
    '_name' => 'profil'
]

#3

Works perfectly, thanks Graziel