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']);
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
you have too many parameters, connect have only 3 and you gave 4, the _name should be in 3rd array
connect
_name
[ 'username' => '[a-z0-9-_]+', 'pass' => ['username'], '_name' => 'profil' ]
Works perfectly, thanks Graziel
This shows up first in search, so I will add:
Always remember to call bin/cake cache clear_all, even in debug mode!
bin/cake cache clear_all
If you don’t, your new route you just defined won’t get loaded.