thinkphp5.0 Development Code

Source: Internet
Author: User

Naming conventions

ThinkPHP5FollowPSR-2Naming conventions andPSR-4Automatically load specifications, and note the following specifications:

Directories and files
    • Directory does not enforce the specification, hump and lowercase + underline mode are supported;
    • Class Library, function file unification to .php be suffix;
    • The file name of the class is defined in the namespace, and the path to the namespace is the same as the path to the class library file;
    • The class name and the class file name are consistent, using the Hump method to name (capitalize);
Functions and classes, property naming
  • Class is named with the Hump method, and the first letter is capitalized, for example User、UserType, you do not need to add a suffix by default, such asUserControllerShould be named directly asUser;
  • The name of the function uses lowercase letters and underscores (lowercase letters begin) In a way that is, for example get_client_ip ;
  • The name of the method uses the Hump method, and the first letter is lowercase, for example getUserName ;
  • The
  • property is named using the Hump method, and the first letter is lowercase, for example  tablename , instance ;
  • A function or method preceded by a double underscore "__" as a magical method, for example __call __autoload ;
Constants and configurations
  • The
  • constants are named with uppercase letters and underscores, such as  app_path and  think_path ;
  • Configuration parameters are named with lowercase letters and underscores, for example, url_route_on and url_convert ;
Data tables and fields
  • Data tables and fields are named in lowercase and underlined, and note that field names do not start with an underscore, such as think_user tables and user_name fields, and it is not recommended to use hump and Chinese as the table field name.
Application Class Library namespace specification

The root namespace of the Application class library is unified as an app (you can setapp_namespaceConfiguration parameter change);
For example:app\index\controller\IndexAndapp\index\model\User。

Avoid using PHP reserved words (see http://php.net/manual/zh/reserved.keywords.php ) as constants, class names and method names, and namespace naming, which can cause system errors.

thinkphp5.0 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.