2012-08-12 59 views
0

这是我当前的目录设置。使用一个配置目录为多个应用程序文件夹

application 
- controllers 
- models 
- views 
- config 
- errors 

public <-- document root 
- images 
- js 
- css 

我想要做的是设置它像这样

frontapp 
- controllers 
- models 
- views 

membersapp 
- controllers 
- models 
- views 

adminapp 
- controllers 
- models 
- views 

config 
errors 
public 

这个设置将让我拥有所有的控制器,模型和应用程序的每个部分组织的观点。我的问题是如何将config和errors目录移出应用程序目录并允许它用于每个应用程序部分?唯一的办法,我看到这可能是如果我修改系统文件,但我不想这样做,因为更新会吸。如果有更好的方式来做我想做的事,让我也知道。谢谢

ps:是我试图做什么称为模块?

回答

1

你总是可以在创建每个应用的符号链接到你的配置和错误的文件夹:

ln -s config frontapp/config 
ln -s config membersapp/config 
ln -s config adminapp/config 

ln -s errors frontapp/config 
ln -s errors membersapp/config 
ln -s errors adminapp/config 

符号连接也将在流行的版本控制系统,如git的结转。

这招也是非常有用的链接根据环境不同的配置文件:

Dev: ln -s config-dev config 
Stage: ln -s config-stage config 
Production: ln -s config-prod config 
+0

谢谢你的评论,如果你不介意,你能解释一下LN?我在终端尝试了“man ln”,并不真正了解它是如何工作的。是否类似于创建文件的别名?如果这是真的,我需要在每个应用程序文件夹中有这个别名? – 2012-08-12 05:20:35

+0

是的,@SarmenB。 “ln”代表“链接”,完全符合你的描述:它为文件或目录创建一个“别名”。所以“ln -s config frontapp /”会在你的frontapp目录中创建一个别名给“config”。然后你可以用“cd frontapp/config /”来访问它,它的内容将是你最初的“config”目录的内容。 – 2012-08-12 05:24:53

+0

谢谢,我会检查出来,这通常是正确的做事方式吗?或者它是对事物的快速修复? (我可能只是爱上了ln lol) – 2012-08-12 05:28:19

相关问题