Reputation: 2024
When I try to return a PHP view from the controller I keep getting the following error:
The template "AuthBundle::login.php" does not exist.
500 Internal Server Error - InvalidArgumentException
The controller looks like this:
<?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');
}
}
The dev config file:
framework:
templating:
engines: ['php', 'twig']
And the view resides inside AuthBundle/Resources/views/login.php
.
The stack trace shows that the error exists in:
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;
What's wrong?
Upvotes: 1
Views: 532
Reputation: 3135
First, from the doc:
Template Suffix
Every template name also has two extensions that specify the format and engine for that template.
Thus, try to rename file to login.html.php
Upvotes: 2