Differences between ThinkPHP Access Controller and event Controller

Source: Internet
Author: User
Are the two controllers clearly used? A simple example is provided. Are the two controllers clearly used? A simple example is provided.

Reply content:

Are the two controllers clearly used? A simple example is provided.

Framework developers have not provided any good explanations or explanations. They basically rely on the developer's own understanding and do not need to be limited to the framework scope.

3.2.x starts to enable more detailed layers, including Controller, Event, Model, Service, Logic... for the subject issue, the TP suggests that the Controller be used as an "external interaction" (for example, display view, accept Form submission, etc ); event is only A response to an "Internal Event" and can only be called through A (). (For example, if A controller needs to provide an interface method to other controllers, it is best to use Event ). It's a bit difficult to say.

Now I use Event because of the separation of the frontend and backend. All requests use ajax, but permission judgment is not very good (for example, the product list cannot be published, but you can select a product in the form ), therefore, two HTTP request methods, "EVENT" and "EVENT_GET", are extended to correspond to the read and list methods in the controller. The extension method is implemented by routing to SomeEvent.

So let's talk about this thing. Actually, it's just a matter of fact. Let's look at my personal understanding and don't care about these details.

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.