0

Hi I'm fresher for symfony . when i execute the below code it will show error.i installed all the assets of symfony.help me to clear this..!

<?php

namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class StudentController extends Controller
{
    /**
     * @Route("/")
     * @Method({"GET"})
     */
    public function index()
    {
        //  return new Response(
        //   '<html><body><h1>HI,Welcome to Tamilnadu</h1></body></html>'
        // );
        return $this->render('student/index.html.twig');
    }
}

I just put "hello" in (student/index.html.twig),and i commented the basic response function and want to run the return this function.

3
  • How did you install symfony? Did you try it before changes the Response? Commented Jan 29, 2020 at 7:13
  • @GrenierJ Thank you sir.. i just install it from symfony documentation site.At first i got a output for this return new Response(),when i moved to render method got error Commented Jan 29, 2020 at 7:33
  • 5
    @ramsurathkumar-s You probably have symfony version 5. You need to inherit the AbstractController class instead of Controller Commented Jan 29, 2020 at 7:59

1 Answer 1

0

Try this:

 /**
 * @Route("/", name="index")
 * @return Response
 */
public function index():Response{
    return $this->render('student/index.html.twig');
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.