Search code examples
phpapachesymfony

Clean Symfony project - 404 for first controller


I am trying to create a new symfony (6.4) project. I created the project using symfony new --webapp web. Then I created my first controller using symfony console make:controller WebController

The Controller looks like this:

<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class WebController extends AbstractController
{
    #[Route('/web', name: 'app_web')]
    public function index(): Response
    {
        return $this->render('web/index.html.twig', [
            'controller_name' => 'WebController',
        ]);
    }
}

when I call localhost I get the Symfony welcome page. But when I try to call localhost/web i am getting a 404 error. Same with the tutorial for "First Controller" from symfony page.

What is the problem? I am using apache2 on Ubuntu 22.04 inside wsl2

/etc/apache2/sites-available/000-default.conf

DocumentRoot /home/honi/git/web/web/public

/etc/apache2/apache2.conf

<Directory /home/honi/git/web/web/public>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

What is the problem? Am I missing something?


Solution

  • I found the solution here, dont know how I missed it: https://symfony.com/doc/6.4/setup/web_server_configuration.html