In consideration of a problem, mvc is sure to model a directory, view a directory.

58 3

Consider a problem,
Mvc, why must model a directory, view a directory, controller a directory,
Instead of a module, place in a directory:
For example, an order module:
OrderController. Php.
OrderModel. Php.
Orderlist. Phtml.
Orderedit. Phtml.

I think this looks like the order module is developed.
Don't need a moment to find the order folder for the view directory and find the edit template.
For a while again to the model directory, OrderModel.

It's also easier to move to another project. The entire folder is copied.

To add a real point of benefit:
First, for example, you've developed the order module to upload to the server, you just need to pass the order directory to the server, not to the controller directory.
Two, such as you sell software, article modules 1000 block, order module 3000 block...........................
Three, this structure conforms to the human thinking, such as composer, npm, and all modules have their own directory, etc.

As if you want to organize your gallery, you must be a catalogue of the, and a directory of the.
I'm looking for a picture of the old artist, and you'll pack the directory of the old artist to me.
However, most of the existing php frameworks are put in a directory, regardless of whether or not the or.
And then gif is a directory.
What's the structure of this child.

Take the front end for reference.
The project is small, or old, is the css one directory, js a directory, an img directory,
But with a larger project, there's an advanced engineer that must be divided by modules rather than by the file type.

5 Answers

106 2

It isn't true, and who specifies that mvc has to organize the code structure.

In addition, the module approach mentioned in the article is similar to python 's web framework django project code organization, and flask 's blueprint ( blue_print ).