2

I have been doing a lot of research on MVC and file structure. Mainly I've been looking at how to start a new layout. I have downloaded a few open source applications to take a look at file structure and how files are developed.

In the first application it was set up to use the standard way (at least the way it seems to me) of putting all the controllers, models and views each in their respective folders. This is the way that all the books say to do it.

In the second application, all folders are in a modules_core or modules folder where each controller (at least what I would assume to be controllers) are in a folder in there that contain three folders: controller, model, view.

Which of the two versions is accepted as standard and common practice? Are the two applications different because of versions of Codeigniter?

1
  • I apologize for asking the two questions there... I have removed them to help fit into Stack Overflow a bit better. Commented Mar 6, 2012 at 3:18

2 Answers 2

3

The standard of Code Igniter is to use those three folders:

  • Controllers
  • Models
  • Views

You can also create sub folders to better separate your files.

Searching a bit, I found that MyClientBase use something called codeigniter-modular-extensions-hmvc that is like a extension for CI.

Modular Extensions makes the CodeIgniter PHP framework modular. Modules are groups of independent components, typically model, controller and view, arranged in an application modules sub-directory, that can be dropped into other CodeIgniter applications.

HMVC stands for Hierarchical Model View Controller.

I don't have experience with hmvc so I cannot tell you what is better. For the standard CI structure, try to separate well in sub-folders (controllers, views and models) related files and try to use helpers to better reuse your code when you need to use functions in more than one place.

Sign up to request clarification or add additional context in comments.

4 Comments

Modular Extensions is basically increased code organization, and modularity (in theory, if you can avoid cross-module dependencies). Personally, I've never developed a Codeigniter app without it since I began using it. Highly recommend for anything bigger than a few controllers.
+1 for MadM I totally agree, HMVC will increase your production time. Its either that or the helper functions. :/ <?php echo Modules::run('social/facebook');?>//load partial views is sexier than grab_facebook_id_and_do_stuff();
Madmartign: Please write out an actual answer for the question. I would love to give you rep points for a good answer
@bretterer: You need to use @ to ping a user in comments, I just saw your's and Philip's reply. I found this while looking for a duplicate of a similar question. I think discussing the merits of modules is a bit off-topic in this thread, but thank you anyways.
0

I think MyClientBase (which seems to be far from the "standard" exemple), seems to be using HMVC more then MVC.

1 Comment

Ok so are there perks of using HMVC over MVC or MVC over HMVC. what is the difference? so on...

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.