JavaScript-Why do I need to use MVC architecture in PHP development?

Source: Internet
Author: User
The first time I contacted MVC Architecture is the use of the thinkphp framework
I personally think this architecture is very bloated (personal feeling) and not suitable for development. (Not a large company, own personal development).

that you don't see the front-end interface to develop the feeling, feel very strange, always feel and the front end off the section.

So I hope someone can give some reasonable advice, let me have reason to believe that this mode can better help me develop, thank you!

Reply content:

My first exposure to the MVC architecture was the use of the thinkphp framework .
I personally think this architecture is very bloated (personal feeling) and not suitable for development. (Not a large company, own personal development).

that you don't see the front-end interface to develop the feeling, feel very strange, always feel and the front end off the section.

So I hope someone can give some reasonable advice, let me have reason to believe that this mode can better help me develop, thank you!

MVC is not only a development model, but also a serious philosophy of collaboration, a typical embodiment of software development.

Software development has a famous saying: " cohesion Poly, low coupling ." In a large project, each function has to be separated. At this point requires each module must do their own things, only and other modules to do the necessary interaction, to establish the necessary logical relationship, and absolutely not into the internal logic of others.

Only in this way can a complete project be built up in pieces. If everyone's development is "reaching", then the project must be destroyed in the relations between the departments, exchanges, blame and wrangling.

" can't see the front-end interface to develop the feeling, feel very strange, always feel and the front end off the section "?
According to my opinion, it is right to take off the festival. If the back-end logic of PHP, and the HTML front-end code into a group of paste, that is the real nightmare.

This is the benefit of the framework: the framework enforces the separation of business logic from the structural requirements. This is easy for individuals to board destroyer habits, for groups easy to work together.

So the learning framework is not only applied, but also a developmental habit. Because if you are serious about PHP development as a career, then the integration of community development is a matter of the sooner or later. In this way, even if there is no formed framework, there will be a group of internally coordinated business separation structure. If I can't adapt, I'm afraid it will be troublesome.

Can't see the front end? Good, I would rather first put the ugliest (even without CSS) front end, debugging stability, and then go to the Internet to grill style.

MVC architecture, in the end, is mostly a concept, in fact, it may not need to use a molding framework to achieve. You can first consider a set of template engine, completely throw PHP simple to do the foreground html/css (V), and then the database read and write operations into blocks (M), and finally a set of URL structure, used to invoke the template or call the background operation (C), in fact, such an MVC structure, it is naturally made.

MVC is not just a PHP concept, it is PHP from other languages, and now almost all PHP frameworks have some form of MVC thought.

The core of MVC is the separation of data operations (Model), front-end pages (View), Business logic (Controller), and each part can be replaced by a separate work.

For example, the front-end page and the business logic separate, can directly the front-end page to the front-end designers to modify, front-end designers do not need to understand PHP and business logic. It's not a disconnect, it's a division of labor.
For example, when changing from one data source (database) to another, only the Model can be modified, and neither the front end nor the business logic need to be modified.

Also, don't you think the code will be clearer if you separate the three parts. Imagine how it hurts to spell HTML in PHP and switch PHP tags over and over in HTML.

MVC is the current trend, the individual think that as long as an application has more than one page, there is the need to adopt the MVC pattern.
As you say the more bloated ... This may be thinkphp rather bloated, MVC is just thought, and there are a lot of lightweight MVC frameworks.

Upstairs to the MVC to do a lot of explanations, do not want to say more, to tell you the reason for confusion:

    1. You did a project that was too small to be an advantage to MVC. Therefore, if it is a small project, it is not necessary to use the MVC pattern development, how to quickly and easily how to do it, or choose some lightweight framework
    2. You're a personal development rather than a team developer, and MVC still doesn't have the edge. When you've been through a lot of people collaborating on a project, you'll naturally understand how important and convenient it is to have a framework of existing rules that govern there.
    3. What you can do is basically a one-time development, not a continuous iteration, or post-maintenance. When you have a large project that needs to expand functionality, modify the data layer, the logic layer, the presentation layer, you will understand the advantages of the MVC pattern.

In short, use the right tools for the right scenario, and don't be overly careful. At the same time, do not feel that some of the current design patterns have been widely proven useless, although you may not use now, but still should use more, more research, more accumulation, will someday Taichetaiwu.

It seems that the landlord is just working soon or students it?
You have this feeling because what you're doing is "personal development," and if you're as bitter as I am, there's no question about hundreds of megabytes of shit on the source code.

PHP is an interpreted language, but there is no need to overemphasize MVC.

However, with the development of the team, it is necessary to split the necessary business logic according to the Division of labor.

From the experience of my personal study, a lot of things that seem to be cumbersome at the moment, in fact, are useful, but this applies to the scene has not yet encountered, or did not go into deep excavation, realize the benefits of this.

Software development to a certain scale, the more emphasis on the concept of layering, the different functions of isolation, that is, decoupling, in this process, MVC is a more typical concept of the macro-layered, the most basic three-layer concept to differentiate.

In fact, thinkphp is not a bloated framework, is also relatively lightweight, the proposed master in the process of learning, do not pay special attention to these concepts, step by step learning, even if a certain kind of thinking is wrong, is also a supplement to themselves. After using the framework, you can take a look at the framework of the source code, for oneself is also an upgrade

Size problem? Do things too small really no use is not as good as direct writing, but the comprehensive consideration of the expansion of what, the advantages are gradually reflected.

Let me say here that the above is not clear: development is only part of a product or project. If you're just comfortable with development and you're an individual developer, then maybe MVC doesn't mean much to you. But for team development and post-maintenance, the concept of MVC can never be overlooked. Imagine a team of seven or eight people who develop a lot of business logic, but you can't separate the business, the view, the data, or even seven or eight people need to operate a place at the same time. Is the efficiency high? This is only at the development level. What if later maintenance? For some online products, the development cycle may be much shorter than the maintenance cycle. If you do not do a good job of modular management, later maintenance will be a very painful thing. You think so, right?

Project you have developed, but the customer suddenly asked you to be able to do multiple front-end templates, and can switch freely, if you use HTML promiscuous mode, is not to cry? Without template separation, business separation, if your code to others to see, that people are going crazy

thinkphp not a bloated bar, you have not seen Yii Laravel Zend ...

Thinkphp is the grammar is too wonderful, the study cost is a bit high, you can look at the corephp, very simple template syntax almost no learning, a two minutes to learn

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.