Why is the "PHP" MVC framework so difficult! 4 years later, I finally realized that I was thinkphp.

Source: Internet
Author: User
This post is for those PHP programmers who have been thinkphp by name (by default7#zbphp.com)


Several of my posts 4 years ago

Posts 1 " arguing with other people about the MVC problem in PHP"http://bbs.csdn.net/topics/350216861
Comment posted: 2010-12-10 22:38:53
In fact, this post was used thinkphp, but the operation is very slow, and the URL is not up, and finally gave up the use of the MVC framework!

Posts 2 " seemingly suddenly understood the MVC model"http://bbs.csdn.net/topics/390332774
Comment posted: 2012-12-29 16:47:22
The problem with MVC's understanding of this post is that it is Factory mode, not MVC mode.



PHP MVC really torture people AH!!! ~

MVC is the abbreviation of Model View controller and is a programming method. But although I have been working for five or six years, I have been a PHP programmer, but never used the MVC framework has been more and more confused by MVC. The domestic MVC framework is basically thinkphp, many times looking for work, because there is no MVC, because no thinkphp framework, so has been a wall, more and more confused doubt depression.

This time once again bite the bullet to understand the mentality of mastering, re-read the thinkphp framework of the official website information, but still very sorry, the URL corresponds here still did not read, the more see dizzy. It's not about MVC, is it? Why is there no controller class? Why is there an action class? “ Controller"Why is it gone, but there is an Action?" Why are there "URL parameters a" and "parameter M"? Does "parameter a" mean "action class"? "Parameter M" is not referring to "model class"??


thinkphp, why is it so hard ?
 
  Display ();    }    Public Function Login () {        $this->display ();    }    Public Function Register () {        $this->display ();    }}

Every time I see Thinkphp's proud routing URLs, I feel dizzy! Index.php?a=&m=, see such a URL, the heart will think "parameter a value" should refer to "Action Class" bar, that number "parameter M" should refer to the Model bar in MVC (models)?

But what do you think is wrong?
Action is the meaning of the action, MVC is the Model View controller, so why don't you see the controller class? Then look carefully, the original action in the thinkphp is the controller (but why should be named Action??). Why not just name the controller?? )

Then the parameter m, the first understanding is the Model class bar. But even more strange, such as visiting the Index.php?a=index&m=content, that follow the idea of the class indexaction below the content () method, but unfortunately, wrong. He is visiting the index () method under Class contentaction ...

When you get here, you'll see why the thinkphp framework is so difficult to be so complicated, because he used a very confusing way to name the key parts .

Hairenbujian's thinkphp

Written here I really can't help but to say Thinkphp Hairenbujian, named on the
1) The action in the URL parameters a and class;
2) The model of the URL parameter m and the class;
3) is the MVC framework but uses the action class to represent the controller;

Because of these three points, most of the PHP programmers who want to figure out MVC are confused every time they look at it!

If Thinkphp writes like this, most people will immediately understand the MVC architecture
 
  Display ();    }    Access address Index.php?c=member&a=login public    function loginaction () {        $this->display ();    }    Access address Index.php?c=member&a=register public    function registeraction () {        $this->display ();}    }



written in the last

Latest news, thinkphp latest version 3.2.x corrected these points, and the action class was renamed Controller. The M parameter in the URL has been changed to C parameter, which becomes intuitive and understandable!
Final speech: For several years has been plagued by MVC, the more to study thinkphp feel confused. All the way, all the wrong, fortunately insisted, or really be made to give up completely. (Welcome Exchange by Default7#zbphp.com)






Reply to discussion (solution)

What does the great God think of ZF?

It makes sense to call an Action, not a Controller.
The Action base class completes the work of the Controller
The class that is derived from the Action completes the work of the model (business model)
And the Model class is just a map of the data table

Actually take a look at the development manual will know, why it takes 4 years?

May the landlord treasure

May the landlord treasure


Thank you!

It makes sense to call an Action, not a Controller.
The Action base class completes the work of the Controller
The class that is derived from the Action completes the work of the model (business model)
And the Model class is just a map of the data table
Actually take a look at the development manual will know, why it takes 4 years?



Study, that's it. But if the name of controller is really good to understand. Starting with M A to action.class and model.class to think, so cause has been confused thinkphp mvc.

Is it so hard to understand?


Yes, but I'm???. The Lord is pleased with the way he was born.
??? What's important is you?

The mind and the frame are two things, the thought must have, the framework does not necessarily need to use.

Always feel that thinkphp is a factory model.

Mainly because, thinkphp is "draw on" ssh, in ssh inside the MVC is named like this.

Mainly because, thinkphp is "draw on" ssh, in ssh inside the MVC is named like this.



Read it again today, probably read it. But distributed architectures, HTTPSQS, sphinx, these are useless.
Computer configuration is too low, install IDE CPU 100%

You're mistaken, thinkphp 2.x is what you say action, is the clearest, the code is also the most easy to understand
Now the thinkphp 3.x, but become complex and understandable.

Always feel that thinkphp is a factory model.


Why do you think so?

In fact, the m in the address is module modules A is the method action
Modules and methods to locate a controller method at the same time, so that Module+action=controller address in the M+a=c
In MVC, M is model, cannot be called by address, and must be called internally by the system.
You're going to freak out. Modules and models of English are confused by the beginning of M ...

It should be clear that:
MVC = model + view + Controller
Controller = module + action

A lot of things need to be enlightened.

This way. How are we going to live for beginners?

  • Related Article

    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.