Answer the question
In order to leave comments, you need to log in
Symfony Route not working?
Good afternoon, I started learning Symfony here, how to create pages for the router correctly.
That's not how it works.
class DefaultController extends Controller
{
/**
* @Route("/", name="homepage")
*/
public function indexAction(Request $request)
{
// replace this example code with whatever you need
return $this->render('default/index.html.twig', [
'base_dir' => realpath($this->getParameter('kernel.project_dir')).DIRECTORY_SEPARATOR,
]);
}
/**
* @Route("/page" name="page")
*/
public function pageAction(Request $request) {
return $this->render('default/page.html.twig', [
'base_dir' => realpath($this->getParameter('kernel.project_dir')).DIRECTORY_SEPARATOR,
]);
}
}
$kernel = new AppKernel('prod', true);
$kernel = new AppKernel('prod', false);
app:
resource: '@AppBundle/Controller/'
type: annotation
Answer the question
In order to leave comments, you need to log in
Even though the issue has already been resolved. But for those who will still face the problem and will not find a solution. On Symfony 5, I did not have all the routes except the root one, it turned out that I had to put "FallbackResource /index.php" in the Apache config (of course, this is only for those cases if you have an apache web server) where "Directory". Actually, this problem is covered on the official website.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question