Home > Mobile >  404 not found when navigate by route on symfony
404 not found when navigate by route on symfony

Time:09-10

When i navigate on route i can't see my page web , i has just get 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 (not relevant to question)

{# 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