[PHP] why is the MVC framework so difficult! After four years, I finally realized that ThinkPHP was the victim.

Source: Internet
Author: User
[PHP] why is the MVC framework so difficult! After four years, I finally understood that ThinkPHP had this post and sent it to PHP programmers who were confused by ThinkPHP's name ~ (By default7 # zbphp.com)


Several posts I posted four years ago

Post 1 《 Argue with others about MVC in PHPHttp://bbs.csdn.net/topics/350216861
Posted on: 22:38:53
In fact, this post was using ThinkPHP at the time, but it was very slow to run, and the website could not be correct, and finally gave up using the MVC framework!

Post 2 《 It seems that I suddenly understood the MVC model.Http://bbs.csdn.net/topics/390332774
Posted on: 16:47:22
In this post, I am wrong about MVC. the method is factory mode, not MVC mode.



Php mvc is really tough !!!~

MVC is short for Model View Controller and a programming method. Although I have been working as a PHP programmer since year 56, I have never used the MVC framework, and I have been confused by MVC. The domestic MVC framework is basically ThinkPHP. I have been looking for a job many times, because I don't need the ThinkPHP framework, so I have been hitting the wall and become increasingly confused and confused.

This time, I tried to understand my mind and read ThinkPHP's official website again. However, I am sorry that I still didn't understand the ThinkPHP framework. the more I see it, the more I feel dizzy. Isn't it MVC, Why is there no Controller class?Why is there an Action class? " Controller"Why does it disappear, but there is an" Action "? Why are there url parameters a and m "? Does "parameter a" refer to "Action Class "? Does "parameter m" refer to "Model class "??


Why is ThinkPHP so difficult?
 Display ();} public function login () {$ this-> display ();} public function register () {$ this-> display ();}}

Every time I see ThinkPHP's proud route URL, I feel dizzy! Index. php? A = & m =. when you see such a URL, you will think that "the value of parameter a" should refer to "Action Class, so the number of "parameter m" should refer to the Model in MVC (Model )?

But I think it's wrong.
Action means Action. MVC is Model View Controller. Why didn't the Controller class be seen? Later, I took a closer look. the original Action is the controller in ThinkPHP (but why is it called Action ?? Why not name it Controller directly ??)

Let's talk about the parameter m, which is the Model class at the beginning. But it is even more strange, such as accessing index. php? A = index & m = content. in this way, the content () method under the class IndexAction is accessed. Unfortunately, it is wrong. The index () method under class ContentAction is accessed...

At this point, you will understand why the ThinkPHP framework is so complex, Because he used a confusing method to name the key part..

Harmful ThinkPHP

I can't help but say ThinkPHP is harmful, and the name is correct.
1) URL parameters a and actions in the class;
2) URL parameters m and the Model in the class;
3) It is an MVC framework, but it uses the Action class to represent the Controller;

These three points make the vast majority of PHP programmers who want to understand MVC confused every time!

If ThinkPHP is written 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 ();}}



Conclusion

According to the latest message, ThinkPHP's latest version 3.2.x corrected these points and changed the Action class to Controller. The m parameter in the URL is changed to the c parameter, which is easy to understand!
Finally, I was troubled by MVC for several years. The more I studied ThinkPHP, the more I felt confused. All the way, all the way wrong, it's better to stick to it, or it's really done to give up. (Welcome to by ult7 # zbphp.com)






Reply to discussion (solution)

What do you think of zf?

It makes sense to call Action instead of Controller.
The Action base class completes the Controller's work
The class derived from Action completes the work of Model (business Model ).
The Model class only maps data tables.

As a matter of fact, I can see the development manual carefully. why should it take four years?

May the landlord cherish it

May the landlord cherish it


Thank you!

It makes sense to call Action instead of Controller.
The Action base class completes the Controller's work
The class derived from Action completes the work of Model (business Model ).
The Model class only maps data tables.
As a matter of fact, I can see the development manual carefully. why should it take four years?



I learned this. However, it is understandable to name it Controller. At the beginning, m a was taken to Action. Class and Model. class, so ThinkPHP mvc was never understood.

Is it so hard to understand?


? But chrysanthemum one ?, But me? Yes ??? Master? Yu Tong? And I am very pleased.
??? Short ?, What matters is you? Why? Now

There are two things: Thought and framework, which must be thought-provoking and not necessarily used.

ThinkPHP is a factory model.

The main reason is that thinkphp uses SSH as a reference, and MVC in SSH is named like this.

The main reason is that thinkphp uses SSH as a reference, and MVC in SSH is named like this.



I read it again today and probably understood it. However, distributed architecture, HTTPSQS, and sphtasks are useless.
The computer configuration is too low, and the CPU usage is 100% when the IDE is installed.

You are mistaken. thinkphp 2.x, which is what action you are talking about, is the clearest, and the code is also the easiest to understand.
Now thinkphp 3.xis complicated and difficult to understand.

ThinkPHP is a factory model.


Why do you think so!

In fact, m in the address is module. module a is the method action.
The module and method locate a controller method at the same time, so module + action = controller is the m + a = c
M in MVC is a model and cannot be called using addresses. it must be called within the system...
It's strange that the English letters of the modules and models start with "m...

In this case, we should clearly understand:
Mvc = model + view + controller
Controller = module + action

Many things need to be realized

In this way. How can we become a newbie?

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.