Reputation: 1291
I updated my project to Symfony4. When I go to some page with a form I have this error appearing :
Unable to find template "StarRatingBundle::rating.html.twig"
(looked into: /templates, /templates, \vendor\symfony\twig-bridge/Resources/views/Form).
I use blackknight467/star-rating-bundle
a bundle which provides a twig extension to have a star rating system. The template in the error is located in this bundle Resources/views
folder.
Twig.yaml :
twig:
paths: ['%kernel.project_dir%/templates']
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
form_themes:
- 'Form/fields.html.twig'
Upvotes: 1
Views: 6682
Reputation: 317
I struggled with the issue when creating a symfony 5 bundle. Make sure you keep your twig templates in <project-folder>/Resources/views
folder. In your Controller, using HelloworldController
as an example:
`<?php
namespace Example\HelloBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class HelloController extends AbstractController
{
public function index(): Response
{
return $this->render('@<BundleName>/hello/index.html.twig', [
'controller_name' => 'HelloController',
]);
}
}
is the name of your bundle without the bundle suffix. For example if you registered your bundle as Example\HelloBundle\ExampleHelloBundle::class => ['all' => true],
in Bundles.php then <BundleName>
is ExampleHello
Upvotes: 0
Reputation: 303
Symfony 4+ does not support “x:x:x.html.twig” notation. You need to install composer require templating
then activate it in your framework.yaml by adding
templating:
engines: ['twig']
.
Files > Invalidate caches & restart. This should allow Symfony to find your templates.
Upvotes: 1