【发布时间】:2018-12-09 01:36:55
【问题描述】:
我是 Symfony 的新手(使用 3.4 版)。我在 macOS High Sierra 上将它与 XAMPP 一起使用。我这样设置我的虚拟主机:
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/project/web/app_dev.php"
ServerName project
</VirtualHost>
并将我的主机文件设置为“127.0.0.1 项目”,效果很好。
但后来我在我的应用程序中创建了一个控制器:
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class ProjectController extends Controller
{
/**
* @Route("/todo", name="todo_list")
*/
public function indexAction(Request $request)
{
die("TO DOS");
// replace this example code with whatever you need
return $this->render('default/index.html.twig', [
'base_dir' => realpath($this-
>getParameter('kernel.project_dir')).DIRECTORY_SEPARATOR,
]);
}
}
但是当我访问项目/待办事项时,它会重定向到项目/仪表板并显示 XAMPP 欢迎页面。我怎样才能去项目/待办事项?
注意:虽然我使用的是 Mac,但我正在学习本教程 https://www.youtube.com/watch?v=HchMW8EhWPU
【问题讨论】: