我正尝试在symfony中创建新页面,但无法访问它
这是我的档案
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class About extends Controller
{
/**
* @Route("/about")
*/
public function aboutAction()
{
return new Response(
'<html><body>This page is about ME</body></html>'
);
}
}当我使用php bin/console debug:router时,它会显示name:app_about_about(我不明白它为什么要这样命名)和path:/about。但是当我试图加载页面时,我得到了404错误
发布于 2016-12-13 04:24:44
导入后重试:
use Symfony\Component\HttpFoundation\Response;
发布于 2016-12-13 22:54:15
只需将文件重命名为./MyBundle/Controller/AboutController.php并重命名该类:
class AboutController extends Controller发布于 2016-12-14 00:08:18
我认为您应该尝试使用路由名称。您还应该将控制器重命名为AboutController。
/**
* @Route("/about", name="about_page")
*/https://stackoverflow.com/questions/41108572
复制相似问题