如何更改 Symfony2 默认结构? [英] How to change Symfony2 default structure?
问题描述
我可以更改默认的 Symfony2 结构以满足我的需要吗?我喜欢下面的结构,但不知道如何让它工作..
May I change the default Symfony2 structure to fit my needs? I like the follow structure, but don't know how to get it to working..
core/ <- Symfony2 core files
app/ <- All applications
app/Acme/ <- Application for Acme enterprise (with all bundles..)
app/clientone.com/ <- Application for Client One enterprise (with all bundles..)
推荐答案
symfony2 发行版内部有 4 个主要目录:
Inside symfony2 distribution there are 4 main directories:
- 应用(对您的应用进行了自定义)
- 供应商(symfony 和其他库)
- src(您的源代码可能是也可能不是特定于应用程序的,可能有捆绑 ClientoneBundle 只针对此应用程序,但也可以是在您的应用程序中重复使用的包,例如 UserBundle)
- web(http 文档根目录)
因此,如果您有多个应用程序,您可以单独保留供应商.您的每个应用程序可能包含三个目录,例如:- 应用程序/极致/应用程序- 应用程序/acme/src- 应用程序/极致/网络- 应用程序/客户端/应用程序- 应用程序/clientone/src- 应用程序/客户端/网络- some/where/else/in/filesystem/vendor
So if you have several applications you could keep vendors separately. And each of your application may contain three directories like: - apps/acme/app - apps/acme/src - apps/acme/web - apps/clientone/app - apps/clientone/src - apps/clientone/web - some/where/else/in/filesystem/vendor
要实现这样的设置非常简单,您只需编辑您的 autoload.php(位于应用程序目录中),只需将 __DIR__.'/../vendor
替换为__DIR__.'/../vendor
,换句话说,告诉 symfony2 你把供应商搬到别处了.
To implement such setup is very easy,- all you have to do is edit your autoload.php (which resides in app dir), just replace everywhere __DIR__.'/../vendor
to __DIR__.'/../vendor
,
in other words, tell symfony2 that you moved vendors somewhere else.
(我只是将您设置中的应用程序目录重命名为应用程序 - 不要与应用程序目录混淆,在您的每个应用程序中)
(I just renamed app directory in your setup to apps - to be not confused with app directory, inside each of your application)
这篇关于如何更改 Symfony2 默认结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!