Annotation is not working for Symfony 4.2 project

151 Views Asked by At

I just started to learn symfony 4.2 and following symfony official documentation site. My Controller looks like

<?php

// src/Controller/LuckyController.php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class LuckyController
{
    /**
     * @Route("/lucky/number/{max}")
      */
    public function number($max)
    {
        $number = random_int(0, $max);

        return new Response(
            '<html><body>Lucky number: '.$number.'</body></html>'
        );
    }
}

?>

and my URL is http://localhost:8012/symfony/public/lucky/number/10. Annotation is not working here because when I call this on browser I am getting 404 error.

0

There are 0 best solutions below