-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Framework] Template name is not valid #12249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This (to much my knowledge) only happens when the PHP template engine is enabled, when you have only Twig enabled this works as expected. |
My config.yml: framework:
templating:
engines: ['twig'] Seems twig is the only engine enable. Am I right ? |
Hi there! Actually, the problem may just be that the template doesn't exist. Let me show you the error I see when I use the Notice the 3rd error down does say what you have, even though it really shouldn't say this. It looks like if the template exists, it never gets here - it resolves elsewhere. But if it doesn't exist, then it hits this code, which throws this error. @soullivaneuh is this what you're seeing? If not, what Symfony version are you seeing? Regardless, there does seem to be a small "bug" in the error that's being shown here: it should not say that the template format is invalid. |
Just updated to the last version of symfony 2.6-beta. The template, exist and now I have the following error:
Adding |
@soullivaneuh could it be a case-sensitive problem? is the template stored in the |
The directory is |
@soullivaneuh can you post your controller code, the error message and your exact template path again? You originally had Thanks! |
Here an example with a very light controller that just render a view: <?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
/**
* Class DefaultController
*
* @package AppBundle\Controller
* @Route("/")
*/
class DefaultController extends Controller
{
/**
* @Route("/", name="homepage")
* @Method("GET")
*/
public function indexAction()
{
return $this->render('default/index.html.twig');
}
/**
* @Route("/about", name="about")
* @Method("GET")
*/
public function aboutAction()
{
return $this->render('default/about.html.twig');
}
} Here, the views emplacement: $ ls -l app/Resources/views/default/
total 8
-rw-rw-r-- 1 sullivan sullivan 1434 oct. 21 15:22 about.html.twig
-rw-rw-r-- 1 sullivan sullivan 1297 oct. 31 15:22 index.html.twig And then, the error:
If I use Here my symfony version I use, by extracting composer.lock file: "name": "symfony/symfony",
"version": "v2.6.0-BETA1",
"source": {
"type": "git",
"url": "https://github.com/symfony/symfony.git",
"reference": "7bd1d4c0e68e9e2fd9e19c8e5671f71e82a4dc73"
}, |
Using |
@soullivaneuh The Symfony2 plugin for PHPStorm is also able to autocomplete native Twig template names, not only the bundle notation (it may not be configured automatically in the project setting if you started using it before the feature was supported, but you can add the paths manually). Can you do a dump of |
Yes, full path works to but throw Exception on Symfony. In a nutshell:
Results of
And my framework config extract: framework:
templating:
engines: ['twig'] |
OK, can you do a dump of the engine itself, to see which engines are registered in its |
Btw, for |
Indeed,
Seems to be same engines... I also include $container->loadFromExtension('framework', array(
'templating' => array(
'engines' => array('twig'),
'assets_version' => uniqid(),
'assets_version_format' => '%%s?v=%%s'
),
)); Could it be linked? |
It was the issue! :) By commented 'engines' in $container->loadFromExtension('framework', array(
'templating' => array(
// 'engines' => array('twig'),
'assets_version' => uniqid(),
'assets_version_format' => '%%s?v=%%s'
),
)); I have now only one engine and But the question is, why having two engines cause this error? Not really clear for me... |
@soullivaneuh this is because the DelegatingEngine relies on Regarding the engines, we should probably apply array_unique on the list of engines to avoid duplicates when |
Ok if I understand well the bug is cause by twice So if I want later to user Thanks for your explanations. |
@soullivaneuh no, as soon as you enable several engines, you will have the bug seen here. The reason why it appeared for you is because you enabled twig twice (once in each config file). What I'm saying is that we could be smart enough to avoid registering the same engine multiple times (which is only wasting time in the delegating engine), which will solve it for the case of listing twig several times. |
Ok for me, issue solved. |
@stof is this something that should actually be fixed? Do we have an issue for this? |
It is something which should be fixed. I think there was already some discussion related to this bug, but I cannot find the issue and I'm not sure it was in this repo (maybe it happened in the doc repo during a review), so I'm reopening this issue to keep track of it. |
#6919 (original issue) Documented side-effect. |
@sstok the "original issue" is a totally different topic. The current issue is not related to bundle inheritance at all |
…he shortcut n... (aitboudad) This PR was merged into the 2.3 branch. Discussion ---------- [FrameworkBundle][Template name] avoid error message for the shortcut n... | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Fixed tickets | #12249, #12254 | Tests pass? | yes | License | MIT Commits ------- 055129c [FrameworkBundle][Template name] avoid error message for the shortcut notation.
By following the Templates section on Best Practices book, I should have the following code in my controller:
This throw the following exception:
I'm using
"symfony/symfony": "2.6.*"
.I think the template path validator should be reviewed, isn't it ?
Thanks.
The text was updated successfully, but these errors were encountered: