我有一个问题 - 当它放在子目录中时,我不能在另一个twig文件中包含一个twig文件.例:
我有一个文件AppUserBundle:Dashboard:index.html.twig
(symfony路径是src/App/UserBundle/Resorcues/views/Dashboard/index.html.twig
其他视图的路径).在那个文件中,我有一个包含Status.html.twig
在AppUserBundle:Dashboard:User
子目录中的文件.但是当试图包含它时,我收到消息"无法找到模板".
{% include 'AppUserBundle:Dashboard:User:Status.html.twig' %}
Run Code Online (Sandbox Code Playgroud)
当我将Status.html.twig文件移动到AppUserBundle:Dashboard
目录并包含它时,一切正常.我可以以某种方式获得这样的文件吗?
AppUserBundle:Dashboard:Subdir:file
Run Code Online (Sandbox Code Playgroud) 是否有可能从config中的子目录导入services.yml文件?
我有这样的结构:
[Acme/MyBundle/Resources]
--[config]
----[routing]
----[services]
------[User]
--------services.yml
----[validation]
----routing.yml
----services.yml
----validation.yml
Run Code Online (Sandbox Code Playgroud)
现在我想导入文件Acme/MyBundle/Resources/config/services/User/services.yml
到Acme/MyBundle/Resources/config/services.yml
,这是在装DependencyInjection/AcmeMyExtension
.代码Acme/MyBundle/Resources/config/services.yml
是:
imports:
- { resource: "@AcmeMyBundle/Resources/config/services/User/services.yml" }
services:
//other services
Run Code Online (Sandbox Code Playgroud)
我收到错误:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'The file "@AcmeMyBundle/Resources/config/services/User/services.yml" does not exist (in: ., C:\wamp\www\dir\src\Acme\MyBundle\DependencyInjection/../Resources/config).' in C:\wamp\www\dir\app\cache\dev\classes.php:1518
Stack trace: #0 C:\wamp\www\dir\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\FileLoader.php(70): Symfony\Component\Config\FileLocator->locate('@AcmeMyBundle/...', '.', false) #1 C:\wamp\www\dir\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php(97): Symfony\Component\Config\Loader\FileLoader->import('@AcmeMyBundle/...', NULL, false, 'services.yml') #2 C:\wamp\www\dir\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php(54): Symfony\Component\DependencyInjection\Loader\YamlFileLoader->parseImports(Array, 'services.yml') #3 C:\wamp\www\dir\src\Acme\MyBundle\DependencyInjection\AcmeMyExtension.php(26): Symfony\Co in C:\wamp\www\dir\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\FileLoader.php on line 100
Run Code Online (Sandbox Code Playgroud)
Acme/MyBundle/DependencyInjection/AcmeMyExtension.php的代码:
<?php
namespace Core\MpgBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder; …
Run Code Online (Sandbox Code Playgroud)