简体   繁体   English

如何到达login.php ..找不到对象symfony3

[英]how to reach login.php.. Object not found symfony3

Hello I want to reach my login.php code.. but i got firstly redirect to / (home) error 你好我想要达到我的login.php代码..但我首先重定向到/(home) 错误

I have one controller and its my code 我有一个控制器和我的代码

/**
     * @Route("/{champ}", name="home", defaults={"champ" = 1})
     */
    public function mainAction(Request $request,champion $champ)
    {

        $user = $this->getUser();
        $form = $this->createForm(UserType::class, $user);
        $champi = new champion();;
        $form2 = $this->createForm(ChampionType::class, $champi);
        $form3 = $this->createForm(ChampionsType::class, $champ);
        $form4 = $this->createForm(ChampionTypes::class, $champ);
        $form2->handleRequest($request);
        $form->handleRequest($request);
        $form3->handleRequest($request);
        $form4->handleRequest($request);
        if ($form->isValid() && $form->isSubmitted()) {
            $password = $this->get('security.password_encoder')
                ->encodePassword($user, $user->getPlainPassword());
            $user->setPassword($password);
            $em = $this->getDoctrine()->getEntityManager();
            $em->persist($user);
            $em->flush();
            $this->addFlash("success", '');
        }
        if ($form2->isValid() && $form2->isSubmitted()) {
            $em = $this->getDoctrine()->getEntityManager();
            $em->persist($champi);
            $em->flush();
            $this->addFlash("success", '');
        }
        if ($form3->isValid() && $form3->isSubmitted()) {
            $em = $this->getDoctrine()->getEntityManager();
            $em->persist($champ);
            $em->flush();
            $this->addFlash("success", '');
        }
        if ($form4->isValid() && $form4->isSubmitted()) {
            $em = $this->getDoctrine()->getEntityManager();
            $em->remove($champ);
            $em->flush();
            $this->addFlash("success", '');
        }

        $champ = $this->getDoctrine()
            ->getRepository('AppBundle:champion')
            ->findAll();
        $champs = $this->getDoctrine()
            ->getRepository('AppBundle:champion')
            ->findAll();

        return $this->render('AppBundle:uzduotis:index.html.twig', [
            'form' => $form->createView(),
            'form2' => $form2->createView(),
            'form3' => $form3->createView(),
            'form4' => $form4->createView(),
            'user' => $user,
            'champions' => $champ
        ]);
    }


    /**
     * @Route("/login", name="authentication_login")
     *  @Method({"GET","POST"})
     */
    public function loginActionAction(Request $request)
    {
        $authenticationUtils = $this->get('security.authentication_utils');

        // get the login error if there is one
        $error = $authenticationUtils->getLastAuthenticationError();

        // last username entered by the user
        $lastUsername = $authenticationUtils->getLastUsername();

        return $this->render('AppBundle:uzduotis:login.html.twig', array(
            'last_username' => $lastUsername,
            'error' => $error,
        ));
    } 

I try to reach localhost:8000/login but still i got redirected to home.. what did i missed or what? 我尝试访问localhost:8000 /登录但仍然被重定向到家..我错过了什么或什么?

好吧,我没有得到任何回复,所以我如何修复这个..我创建了一个名为ChampController的新控制器..我把我的代码放在不同的路线上...所有与冠军的行动我做了路线../champion/{champ}然后我的与冠军登录没有重复,现在一切正常:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM