Logic flow issues in the controller layer in PHP

Source: Internet
Author: User
A very simple problem feeling should not be affected very much, but it has obsessive-compulsive disorder, not to ask uncomfortable skinner .... For example, a page of the form, there are additions, edits, deletions and other functions, in the controller is to write three corresponding fucntion, or in a method, the act and other logical judgments to distinguish it?
Feel like there is not much difference, but still want to ask what kind of practice better, standardize some

Reply content:

A very simple problem feeling should not be affected very much, but it has obsessive-compulsive disorder, not to ask uncomfortable skinner .... For example, a page of the form, there are additions, edits, deletions and other functions, in the controller is to write three corresponding fucntion, or in a method, the act and other logical judgments to distinguish it?
Feel like there is not much difference, but still want to ask what kind of practice better, standardize some

It's usually three action.
Some special cases will be met add and edit share an action, delete individual one.
The assumption is that the model layer is written to determine how the data is processed (in fact, it is a compatible addition and editing method (; ´ρ ')).

Write separately, for reasons
If you write unit tests, it's good to test them separately.
RBAC makes it easy to set permissions.

Write three actions, regulate restful, and correspond to different request methods, such as Get,post,delete,put

  • 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.