如何更改Symfony2的默认结构?

时间:2022-10-16 18:16:11

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..

我可以更改默认的Symfony2结构以满足我的需求吗?我喜欢以下结构,但不知道如何让它工作..

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..)

1 个解决方案

#1


3  

Inside symfony2 distribution there are 4 main directories:

在symfony2内部分发有4个主要目录:

  • app (there are customisations to your app)
  • 应用程序(您的应用程序有自定义)
  • vendors (symfony and other libraries)
  • 供应商(symfony和其他库)
  • src (your source code which may or may not to be application specific, there could be bundle ClientoneBundle which is specific to only this application, but also could be a bundle reused among your applications,- such as UserBundle)
  • src(您的源代码可能是也可能不是特定于应用程序的,可能只有特定于此应用程序的捆绑ClientoneBundle,但也可能是在您的应用程序中重用的捆绑包,例如UserBundle)
  • web (http document root)
  • web(http文档根目录)

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

因此,如果您有多个应用程序,则可以将供应商分开。每个应用程序可能包含三个目录,如: - apps / acme / app - apps / acme / src - apps / acme / web - apps / clientone / app - apps / clientone / src - apps / clientone / web - some / some其中/其它/中/文件系统/供应商

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.

要实现这样的设置非常简单,所有你需要做的就是编辑autoload.php(它位于app dir中),只需将__DIR __。'/ .. / vendor替换为__DIR __。'/ .. / vendor,in换句话说,告诉symfony2你在其他地方移动了供应商。

(I just renamed app directory in your setup to apps - to be not confused with app directory, inside each of your application)

(我只是将您的设置中的app目录重命名为apps - 不要与app目录混淆,在每个应用程序中)

#1


3  

Inside symfony2 distribution there are 4 main directories:

在symfony2内部分发有4个主要目录:

  • app (there are customisations to your app)
  • 应用程序(您的应用程序有自定义)
  • vendors (symfony and other libraries)
  • 供应商(symfony和其他库)
  • src (your source code which may or may not to be application specific, there could be bundle ClientoneBundle which is specific to only this application, but also could be a bundle reused among your applications,- such as UserBundle)
  • src(您的源代码可能是也可能不是特定于应用程序的,可能只有特定于此应用程序的捆绑ClientoneBundle,但也可能是在您的应用程序中重用的捆绑包,例如UserBundle)
  • web (http document root)
  • web(http文档根目录)

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

因此,如果您有多个应用程序,则可以将供应商分开。每个应用程序可能包含三个目录,如: - apps / acme / app - apps / acme / src - apps / acme / web - apps / clientone / app - apps / clientone / src - apps / clientone / web - some / some其中/其它/中/文件系统/供应商

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.

要实现这样的设置非常简单,所有你需要做的就是编辑autoload.php(它位于app dir中),只需将__DIR __。'/ .. / vendor替换为__DIR __。'/ .. / vendor,in换句话说,告诉symfony2你在其他地方移动了供应商。

(I just renamed app directory in your setup to apps - to be not confused with app directory, inside each of your application)

(我只是将您的设置中的app目录重命名为apps - 不要与app目录混淆,在每个应用程序中)