THINKPHP5 Learning (i)--THINKPHP5 directory structure and Development specification

Source: Internet
Author: User
Tags php database php framework traits

Development specification:

Directories and files
    • The directory uses lowercase + underline;
    • 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 file is named by the Hump method (capitalized), and other files are named with lowercase + underscore;
    • 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 using the Hump method (capitalized), for example UserType , the default does not need to add a suffix, for example User ;
    • The name of the function uses lowercase letters and underscores (lowercase letters begin) In a way that is, for example getUserName ;
    • The name of the method uses the Hump method (the first letter lowercase), for example getUserName ;
    • The name of the property is used in the Hump method (lowercase), for example instance ;
    • A function or method that begins with a double underscore "__" as a magic method, for example __autoload ;
Constants and configurations
    • Constants are named with uppercase letters and underscores, for example THINK_PATH ;
    • Configuration parameters are named with lowercase letters and underscores, for example 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 user_name a field, and are not recommended for use with humps and Chinese as data table fields.

Directories and files
  • The directory uses lowercase + underline;
  • The class library, the function file unify User , UserController should be named directly get_client_ip ;
  • The name of the method uses the Hump method (the first letter lowercase), for exampletableName__callAndAPP_PATHAndurl_route_onAndthink_userTables andProject App Deployment directory ├─application app catalog (configurable)
    │├─common Public Module catalog (can be changed)
    │├─index Module catalog (can be changed)
    ││├─config.php Module Configuration file
    ││├─common.php Module Function file
    ││├─controller Controller Directory
    ││├─model Model Catalog
    ││├─view View Catalog
    ││└─ ... More Class Library Catalogs
    │├─command.php Command line tool configuration file
    │├─common.php applying public (function) files
    │├─config.php Application (Public) profile
    │├─database.php Database configuration file
    │├─tags.php application behavior Extension definition file
    │└─route.php Routing configuration file
    ├─extend Extension Class Library directory (definable)
    ├─public WEB Deployment Directory (external access directory)
    │├─static Static Resource storage directory (Css,js,image)
    │├─index.php Application Portal File
    │├─router.php Quick Test File
    │└─.htaccess for Apache rewrite
    Runtime directory for ├─runtime applications (writable, can be set)
    ├─vendor third-party Class library directory (Composer)
    ├─thinkphp Framework System Catalog
    │├─lang Language Pack Directory
    │├─library Framework Core Class Library Directory
    ││├─think Think class Library package directory
    ││└─traits System Traits Directory
    │├─TPL System Template Directory
    │├─.htaccess for Apache rewrite
    │├─.travis.yml CI Definition File
    │├─base.php Basic Definition file
    │├─composer.json Composer Definition File
    │├─console.php Console Entry File
    │├─convention.php Custom configuration file
    │├─helper.php helper function file (optional)
    │├─license.txt Authorization Note File
    │├─phpunit.xml Unit Test configuration file
    │├─readme.md README File
    │└─start.php Framework Boot File
    ├─build.php auto-Generate definition file (reference)
    ├─composer.json Composer Definition File
    ├─license.txt Authorization Note File
    ├─readme.md README File
    ├─think Command Line entry file

THINKPHP5 Learning (i)--THINKPHP5 directory structure and Development specification

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.