好的,所以我刚刚安装了最新版本的Symfony 4.安装完成后运行浏览器并显示一个不错的欢迎问候语.都好!
然后我使用创建了一个新的控制器make:controller.我将此控制器命名为Client,并使用Annotations,与其他默认控制器相同.我按如下方式配置了路由:
/**
* @Route("/client", name="client")
*/
public function index()
{
// replace this line with your own code!
return $this->render('@Maker/demoPage.html.twig', [ 'path' => str_replace($this->getParameter('kernel.project_dir').'/', '', __FILE__) ]);
}
Run Code Online (Sandbox Code Playgroud)
我刷新浏览器,一切都很好,没有错误.
然后我手动在浏览器中键入路径以检查它是否真的有效:
localhost:8000/client
Run Code Online (Sandbox Code Playgroud)
问题.该网址返回标准apache 404
Not Found
The requested URL /client was not found on this server.
Apache/2.4.18 (Ubuntu) Server at new.staff-fdr.dev Port 80
Run Code Online (Sandbox Code Playgroud)
调试路径看到了这一点:
-------------------------- -------- -------- ------ ------------------
Name Method Scheme Host Path
-------------------------- -------- -------- ------ -----------------
client ANY ANY ANY /client
index ANY ANY …Run Code Online (Sandbox Code Playgroud)