Symfony Framework - Route cannot be found even if it is defined in Controller

32 views Asked by At

I have a multiple Controllers for different Security Levels (So a UserController for pages for users, AdminController for admin pages). I have one Controller where all of the other routes work

class UserProfileController extends AbstractController
{
    #[Route('/user/profile', name: 'app_user_profile')]
    public function index(AuthenticationUtils $authenticationUtils): Response
    {
        $user = $this->getUser();

        return $this->render('user_profile/index.html.twig', [
            'username' => $user,
        ]);
    }

The above is a route that does work.

However i also have a route that is defined in the same Controller that has a Route Parameter, that does not work, i tried to change the route path or clear the cache but it will still not show up, always giving me the error "No route found for "GET https://127.0.0.1:8000/user/registerFor/HillRunHub" (from "https://127.0.0.1:8000/user/events")"

#[Route('/user/registerFor/{eventname}', name: 'new_users_events')]
public function EventRegister(EntityManagerInterface $entityManager, string $eventname, Request $request): Response
    {
          ....
    }

This is in my route.yaml

controllers:
    resource:
        path: ../src/Controller/
        namespace: App\Controller\
    type: attribute

Like i said i tried to clear the cache, change the route path so that it matches or change the route into one that does not have a parameter but the error is always the same. The same also happened to another route on another controller with the difference that that one never had a Route Parameter

0

There are 0 answers