Folder Structure - Am I doing correctly? |
[eluser]Jeffrey04[/eluser]
I'm not sure whether I am doing correctly but following is my folder structure app |-controller ||-module |||-main.php // default controller |||-add.php // for adding records |-model ||-module |||-module_model.php // storing the model for a module |-view ||-module |||-module-action-name.php // storing template however, having a controller class named 'add', I am getting some problem with scaffolding because when I want to add a record, i get to http://project.tld/codeigniter/module/add/ which is my 'add' controller class???
[eluser]gtech[/eluser]
your question seems a bit vague so I will try and interpret what you are trying to do If you have quite a small application there is no real need to split the controllers or models into subdirectories. It sounds like your creating a controller class for every method you want to call which is not necessary as a controller and model can have multiple methods. Say I had a users table, I may want to create a users controller and model eg. |MODELS ||usersdb.php |CONTROLLERS ||users.php the model and controller can then have different methods eg, add a user, remove a user, view all users etc. Code: class Usersdb extends Model Code: class User extends Controller { so to add a user you would use the URL whatever.com/codeigniter/index.php/user/add or am I misinterpreting your problem?
[eluser]Tom Glover[/eluser]
Well said, I hope this helps you Jeffrey04, and also if you are creating a big app you may want to look into HMVC or Matchbox.
[eluser]Jeffrey04[/eluser]
i have re-organized the file structure so that it is more straight forward... but I'm still not very used to having all controller classes saved in a single directory
[eluser]gtech[/eluser]
by all means split them into subdirectories if it makes sense, eg you may have an admin interface you might want to put the administration controllers in the admin directory.. all I was trying to get at is that you can have more than one method in a controller. I tend to have a controller for each table I have in my database. As WakeyWebs suggested HMVC and matchbox are also useful. I know matchbox is used to organize your CI projects modularly, I have not looked into HMVC. |
Welcome Guest, Not a member yet? Register Sign In |