Reputation: 73
I am using symfony 3.2.4 (got with console --version). I am working the openclassroom tutorial. That controller always return the error below. Nevertheless, the file below exist with and is accessible.
src/OC/PlatformBundle/Resources/views/Advert/index.html.twig
I got crazy with that. Does someone have an idea ?
Thanks in advance.
<?php
// src/OC/PlatformBundle/Controller/AdvertController.php
namespace OC\PlatformBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
class AdvertController extends Controller
{
public function indexAction()
{
$content = $this->get('templating')->render('OCPlatformBundle:Advert:index.html.twig');
return new Response($content);
}
}
Unable to find template "OCPlatformBundle:Advert:index.html.twig" (looked into: /var/www/html/symfony/app/Resources/views, /var/www/html/symfony/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form).
*
Upvotes: 0
Views: 546
Reputation: 3125
Did you try to create your template in app/Resources/views/Advert/index.html.twig
?
This is a better practice : Store all your application's templates in app/Resources/views/ directory.
(From SF doc)...
So, you'll be able to "call" it by this way:
/***/
public function indexAction()
{
return $this->render('Advert/index.html.twig', []);
}
/***/
Upvotes: 0