THINKPHP5 onebase Research and Development code

Source: Internet
Author: User

Research and Development Code THINKPHP5Directory and file naming
    • The catalog command uses lowercase underlines.
    • class libraries, function files are unified with. php as the suffix.
    • The file name of the class is defined as a namespace, and the path to the namespace is the same as the path to the class library file.
    • The class file is named with the Hump method (capitalized), and the other files are named with lowercase underlines.
    • The class name and class file name are consistent and are named (capitalized) by the camel.
Functions and classes, property naming
    • The class is named using the Hump method (capitalized), such as User.
    • The name of the function uses lowercase letters and underscores (the beginning of lowercase letters), such as GET_CLIENT_IP.
    • The name of the method uses the Hump method (the first letter lowercase), such as GetUserName.
    • The name of the property uses the Hump method (the first letter lowercase), such as TableName, instance.
    • The class name and class file name are consistent and are named (capitalized) by the camel.
Constants and Configuration naming
    • Constants are named with uppercase letters and underscores, such as App_path.
    • Configuration parameters are named with lowercase letters and underscores, such as url_route_on.
Data table and field naming
    • Data tables and fields are named in lowercase and underlined, and note that field names do not start with an underscore, such as the Think_user table and the User_name field, and it is not recommended to use hump and Chinese as the data table fields.
Coding recommendations
    • Each class (without comments) code should be within 200 lines, and each method (without comment) code should be within 20 lines, with no spaces at the end of each line.
    • Control layer (Controller), the process branch statements such as if else switch are not present as much as possible.
    • The business logic is encapsulated in the logical layer (logic) to be called by the Controller.
    • The Data Model layer (model) is used as much as possible in logical logic, so try not to use model directly in the controller.
    • Data validation is written as far as possible in the validation layer (validate), which is called by the logical layer and is not validated in the controller.
    • Payment | SMS, etc. as far as possible encapsulation as a service to facilitate subsequent expansion, Icon selection | Provincial and county linkage as far as possible to package as a plug-in to facilitate subsequent reuse.
    • API interface as far as possible according to the application interface to implement the combined interface, reduce app interface requests.
    • The non-onebase function as far as possible in the app/function.php file, add non-storage configuration items as far as possible in the ext_config.php file, extend directory extension related functions into the extend.php file.
    • For missing items in other documents, refer to Onebase encoding and naming as much as possible.
    • This article is from: http://www.onebase.org/

THINKPHP5 onebase Research and Development code

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.