I am Confused About CakePHP Routing – Can Someone Explain?

Hey everyone,

I am still pretty new to CakePHP & stuck trying to set up some custom routes. I am working with CakePHP 4.x & want to create a URL such as /blog/category/tech that goes to a category() method inside my PostsController. Also I tried following some examples online but either the route does not register or I get redirected somewhere else entirely.

The official docs cover the basics but I am struggling to understand how to apply them in slightly more customized situations. Maybe I am missing a step or just not setting the parameters correctly.

I have also been switching gears between CakePHP and front-end stuff while doing a reactJS online training, so that might be part of my confusion :sweat_smile:.

If someone could help me out with a clear example or explain what I might be doing wrong, I appreciate it. Also i have check this How to disable auto routing in cakePHP 4.x still i am confused.

Thank you..:slight_smile:

bin/cake routes in the CLI or the Routes tab inside the Debug Kit will show you all configured routes which are recognised by CakePHP.

If your custom route isn’t present inside those definitions you are doing something wrong with your route configuration.

Can you maybe give an example on what route you want to connect incl. the code you think should do the job?