当我尝试从控制器返回PHP视图时,我不断收到以下错误:
The template "AuthBundle::login.php" does not exist.
500 Internal Server Error - InvalidArgumentException
控制器如下所示:
<?php
namespace AuthBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
/**
* @Route("/user")
*/
class UserController extends Controller
{
/**
* @Route("/login", name="login")
*/
public function loginAction()
{
return $this -> render('AuthBundle::login.php');
}
}
开发配置文件:
framework:
templating:
engines: ['php', 'twig']
视图位于AuthBundle/Resources/views/login.php
内。
堆栈跟踪显示错误存在于:
at PhpEngine ->load ('AuthBundle::login.php')
in vendor/symfony/symfony/src/Symfony/Component/Templating/PhpEngine.php at line 72 -
*/
public function render($name, array $parameters = array())
{
$storage = $this->load($name); // here
$key = hash('sha256', serialize($storage));
$this->current = $key;
$this->parents[$key] = null;
出了什么问题?
答案 0 :(得分:2)
首先,来自doc:
模板后缀
每个模板名称还有两个扩展名,用于指定该模板的格式和引擎。
因此,请尝试将文件重命名为login.html.php