2014-10-31 111 views
0

我不理解bundle体系结构的正确性。 我创建了一个父母是FOSUserBundle的包。我想在其他symfony2安装中使用我创建的SHN/UserBundle。Bundle注册在供应商包内

内部的目标应用程序,我收到一个

LogicException: Bundle "SHNUserBundle" extends bundle "FOSUserBundle", which is not registered. 

我的意思是我向应自动注册,因为我SHN/UserBundle使用它的fosuserbundle?

我的思维错误在哪里?

/src/SHN/UserBundle/composer.json:

"name" : "SHN/UserBundle", 
"description" : "Overwrites the FOS Userbundle with some futures", 
"type" : "symfony-bundle", 
"authors" : [{ 
    "name" : "Timo Linde", 
    "email" : "[email protected]", 
    "role" : "Developer" 
}], 
"keywords" : [ 
    "fos-userbundle extend" 
], 
"license" : [ 
    "proprietary" 
], 
"require" : { 
    "php": ">=5.3.3", 
    "friendsofsymfony/user-bundle": "~1.3" 
}, 
"autoload" : { 
    "psr-0" : { 
     "SHN\\UserBundle" : "" 
    } 
}, 
"target-dir" : "SHN/UserBundle", 

回答

1

你确实有束继承模型的一种误解。这不是父母/子女关系(是的,名字很混乱......)。

想象一下模板的情况(如果您只是覆盖模板,请考虑使用the app/Resources dir instead)。当请求模板FOSUserBundle:Security:login.html.twig而不是直接解析@FOSUserBundle/Resources/views/Security/login.html.twig文件时,它首先查找是否存在@TheChildBundle/Resources/views/Security/login.html.twig,如果是,则使用该文件而不是位于FOSU​​serBundle中的文件。

它更像是一种重载关系。

这意味着FOSUserBundle仍然需要注册。

+0

好吧,然后我不想在我的目标应用程序的composer.json的require部分添加FOSUserBundle。因为它已经在我的供应商软件包SHN/Userbundle的供应商文件夹中。我如何从该位置注册?我得到这个异常: 试图从/var/www/shn/app/AppKernel.php第21行中的命名空间“FOS \ UserBundle”加载类“FOSUserBundle”。您是否需要从另一个命名空间“使用”它? – CoKe 2014-10-31 12:41:55

+0

有没有人有关于此的一个想法? – CoKe 2014-11-05 08:21:47

+1

您是否使用作曲家安装软件包?如果是这样,作曲家应该为你做这个 – 2014-11-05 08:54:57

相关问题