我刚开始学习 symfony 4.2 并关注 symfony 官方文档站点。我的控制器看起来像
<?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>'
);
}
}
?>
我的网址是http://localhost:8012/symfony/public/lucky/number/10。注释在这里不起作用,因为当我在浏览器上调用它时,我收到 404 错误。