Home > Software engineering >  404 not found when navigating by route on symphony
404 not found when navigating by route on symphony

Time:09-14

When I navigate on route I can't see my page web, I has just 404 not found

config/routes/attributes.yaml

controllers:
    resource: ../../src/Controller/
    type: attribute

kernel:
    resource: ../../src/Kernel.php
    type: attribute

Controller

namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;

class LuckyController
{
    #[Route('/lucky/number')]
    public function number(): Response
    {
        $number = random_int(0, 100);

        return $this->render('lucky/number.html.twig', [
            'number' => $number,
        ]);
    }
}

Twig

{# templates/lucky/number.html.twig #}
<h1>Your lucky number is {{ number }}</h1>

CodePudding user response:

I think you are need .htaccess for rewrite url , install apache-patch , and it will take care of the config and adding htaccess.

Install apache pack

composer require symfony/apache-pack
  • Related