Welcome Guest, Not a member yet? Register   Sign In
Files structure
#1

[eluser]Gerep[/eluser]
Hi,

I'm trying to find a good way to separate my files into folders.

For instance, I'm saving all my classes related to user on

Quote:controllers/user/user.php
controllers/user/login.php
controllers/user/amnesia.php

and so on...

The bad thing is that when I call the controller user.php I have to place the user folder on my url.

Is there a way to take it or another way to organize my files?

Thanks in advance for any help.
#2

[eluser]adamfairholm[/eluser]
I'd try modules (such as Modular Extensions) to keep your application files in modules and nice and separated:

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/overview

If you want to organize files other than controllers and views, check out packages as well:

http://ellislab.com/codeigniter/user-gui...oader.html
#3

[eluser]donjim[/eluser]
I have a similiar question about the file structure, hope u dont mind I also post in your tread.

Lets say i have companies
Code:
company/view/
company/edit/

I also have persons
Code:
person/view/
person/edit/

And then I would like to add a new person and, bind him/her to an company, what is the nicest or more correct file structure aproach?

could I make company as a folder and then a Controller edit/add? like..
Code:
company/edit/person
or person/company/edit ?

Am I thinking in acceptable MVC terms here?
#4

[eluser]adamfairholm[/eluser]
donjim,

What you are talking about is more application organization than MVC - your URL structure is really up to you, and it is dictated by what the needs of your application are building, so whether you use company/edit/person or person/company/edit, is more of a organization question.

When you edit a person, why not have a drop down for a company as well instead of having a separate method for just editing the person's company? That way you could have person/edit and have everything in one place.

I'd recommend getting away from thinking of the first URI segment as a folder though, with different controllers for edit and view and other operations like that. If you have a company controller, then you can have edit and view functions within those, and keep things a lot cleaner. You can use routes to route more complex urls to your controllers as well.

Hope that helps!

Adam
#5

[eluser]InsiteFX[/eluser]
With HMVC your structure would be like this:
Code:
modules - root of modules.
  -- module name - your controller must match the module name.
  ---- controllers - your controllers are here
  ---- config
  ---- helpers
  ---- libraries
  ---- models
  ---- etc
  ---- views - your view files are here
  -- another module etc

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB