Welcome Guest, Not a member yet? Register   Sign In
Large Application, want to create SubDirs in MVC folders
#1

[eluser]GChester[/eluser]
We have a large application we are developing. Think of it kinda like an accounting package that has modules and I'm wondering if I can create separate folders in the MVC folders to hold the modules.

For example in the Views folder can I have:

views\module1
views\module2
views\module3

If not how would be the best way to organize a large project like this. I hate to simply dump all the files in together and have an unmanageable mess.

g
#2

[eluser]boltsabre[/eluser]
- You can certainly organise your views like this, nest them as deep as you want to.
- Controllers can also be organised into sub folders like this as well, I think by default it can only go one folder deep, but you can get around this (you'll have to research how to do this yourself, I personally haven't done it more than one folder deep because it's not needed on my application).
- Not sure about nesting models, never tried it.

However, I think that HMVC is what you're after, you can organise each "module" into its own folder with it's own Models, Controllers, Views, Libraries, Helpers, Configs, etc. So you may have a "authentication module, a tax module, a invoice module, a income vs expenses module, etc, etc, each one dedicated to that particular functionality, completely isolated (I terms of location) from each other.
Research it, interesting stuff and I believe would be best for you if your application is as big as you suggest it will be.

Good luck!
#3

[eluser]PhilTem[/eluser]
Hi GChester,

I can only confirm, what @boltsabre said so far, you can nest your views indefinitely deep (of course, only as long as the OS supports the length of the path) you only need to make the argument to $this->load->view() match the path Wink
By default, CI only supports one level of folders in the APPPATH . 'controllers' folder, however, you can extend CI_Router with MY_Router and make it find controllers in any sub-folder, no matter how deep it is.

On the other hand, you might really want to go for HMVC (the best one IMHO is from @wiredesignz) which helps you separate the business logic of your large application even better since everything is separated by, let's say, categories i.e. by what it's dealing with Wink

As far as my knowledge on CI 3.0 goes, HMVC will be supported by CI by default, yet only in a light version (don't know an exact comparison with @wiredesignz' implementation Wink




Theme © iAndrew 2016 - Forum software by © MyBB