0

this is my current directory setup.

application
- controllers
- models
- views
- config
- errors

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

what i want to do is set it up like this

frontapp
- controllers
- models
- views

membersapp
- controllers
- models
- views

adminapp
- controllers
- models
- views

config
errors
public

this setup would let me have all the controllers, models, and views organized for each section of the application. My question is how can i move the config and errors directories out of the application directory and allow it to be used for each application sections? The only way i see this possible is if i modified the system files but i dont want to do that because updating is going to suck. If there is a better way of doing what i am trying to accomplish let me know as well. thanks

ps: Is what im trying to do referred to as modular?

1 Answer 1

1

You can always create symbolic links to your config and error folders in each of your apps:

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

The symlink will also carry over in popular versioning systems, such as git.

This trick is also very useful for linking to different configurations files depending on environment:

Dev: ln -s config-dev config
Stage: ln -s config-stage config
Production: ln -s config-prod config
Sign up to request clarification or add additional context in comments.

9 Comments

thank you for the comment, if you dont mind can you explain ln? i tried "man ln" in terminal and dont really understand how it works. Is it similar to creating an alias of a file? if that is true would i need to have that alias inside each application folder?
Yes, @SarmenB. "ln", which stands for "link", does exactly what you described: it create an "alias" to a file, or a directory. So "ln -s config frontapp/" would create an alias to "config" in your frontapp directory. Then you can access it, with "cd frontapp/config/", and its content will be the content of your original "config" directory.
thanks, i'll check it out, is this normally the right way of doing things? or is it a quick fix to things? (i might just fall in love with ln lol)
@SarmenB. This is the recommended way for reusing configuration files across multiples applications, environments, or even sharing sets of files across multiples development environments. Symlinking is one of the best tool of the developer's arsenal.
Nice!, Thank you so much, i like the idea of a config for different production levels.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.