Why my Symfony route is overridden by other routes?

143 Views Asked by At

I use annotations to define routes in my project. I have a controller method that has such a route:

/**
* @Route("/{slug}", name="showcompany")
*/
public function show(Company $company): Response
{
...
}

This is done to catch requests like website.com/company1, website.com/company2, etc...

I get this error:

"App\Entity\Company object not found by the @ParamConverter annotation."

Since obviously all other routes such as website.com/signup are considered as slugs of the Company entity.

The question is how to avoid this behavior without moving all routes to routes.yaml and ordering them manually? I want all routes to be prioritized over this /{slug} route.

0

There are 0 best solutions below