0

I am quite new to Symfony 3. I created the controller files in the AppBundle itself. No new bundle created. Now I am trying to route a new page and it gives an error. This is what I did.

In src\AppBundle\Controller\Patient\PatientController.php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class DefaultController extends Controller
{
    /**
     * @Route("/patient", name="patient_homepage")
    */
    public function patientHomeAction(Request $request)
    {
        // replace this example code with whatever you need
        return $this->render('Patient/home.html.twig', array()
        );
    }

In the app\Resources\views\base.html.twig

<a href="{{ path('patient_homepage') }}">Home</a>

This gives an error as

"An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "patient_homepage" as such route does not exist.") in base.html.twig at line 118."

Do I need to do any changes in the app\config\routing.yml also? What am I missing here.

A.L
  • 10,259
  • 10
  • 67
  • 98
njay
  • 79
  • 10

2 Answers2

1

You have to enable route in app/config/routing.yml

app:
    resource: "@AppBundle/Controller/Patient/"
    type:     annotation
Imanali Mamadiev
  • 2,604
  • 2
  • 15
  • 23
1

Try this

app:
    resource: "@AppBundle/Controller/"
    type:     annotation