ThinkPHP convention configuration-php Tutorial

Source: Internet
Author: User
ThinkPHP convention configuration explanation classification: PHP Time: August 1, February 18, 2015

The ThinkPHP framework is one of the excellent PHP frameworks developed by Chinese people. ThinkPHP documents and code comments are both Chinese and are very easy to learn. The following describes ThinkPHP convention configuration (ThinkPHP \ Conf \ convention. php) framework default settings, including application-related configuration, PHP cookie and session settings, ThinkPHP framework configuration, database connection and data cache configuration, log settings, error template configuration, template engine configuration and layout setting, template label, system variable configuration, and URL path configuration.

1. ThinkPHP application settings

'App _ USE_NAMESPACE '=> true, // whether the application class library uses the namespace

'App _ SUB_DOMAIN_DEPLOY '=> false, // whether to enable sub-domain name deployment

'App _ SUB_DOMAIN_RULES '=> array (), // sub-domain name deployment rules

'App _ DOMAIN_SUFFIX '=> ", // The domain name suffix must be set if it is a suffix such as com.cn net.cn.

'Action _ SUFFIX '=> ", // operation method SUFFIX

'Multi _ module' => true, // whether MULTI-MODULE is allowed. If this parameter is set to false, DEFAULT_MODULE must be set.

'Module _ DENY_LIST '=> array ('common', 'runtime '),

'Controller _ level' => 1,

'App _ AUTOLOAD_LAYER '=> 'Controller, Model', // The automatically loaded application class library layer is valid after the APP_USE_NAMESPACE is disabled.

'App _ AUTOLOAD_PATH '=> ", // The automatically loaded path is valid after the APP_USE_NAMESPACE is disabled.

2. PHP cookie and session settings

/* Cookie settings */

'Cookie _ EXPIRE '=> 0, // COOKIE validity period

'Cookie _ DOMAIN '=> ", // valid cookie domain name

'Cookie _ path' => '/', // COOKIE PATH

'Cookie _ prefix' => ", // avoid conflict with the COOKIE PREFIX

'Cookie _ SECURE '=> false, // SECURE transmission of cookies

'Cookie _ HTTPONLY '=> ", // COOKIE httponly setting

/* SESSION settings */

'Session _ AUTO_START '=> true, // whether to enable the SESSION automatically

'Session _ options' => array (), // The SESSION configuration array supports parameters such as type name id path expire domain.

'Session _ type' => ", // The SESSION hander TYPE does not need to be set by default unless the session hander driver is extended.

'Session _ prefix' => ", // SESSION PREFIX

// 'Var _ SESSION_ID '=> 'session _ id', // submit variable of sessionID

3. configurations of the ThinkPHP framework

'Default _ m_lay' => 'model', // DEFAULT Model layer name

'Default _ C_LAYER '=> 'controller', // DEFAULT Controller layer name

'Default _ v_lay' => 'view', // DEFAULT View layer name

'Default _ lang' => 'zh-cn', // DEFAULT Language

'Default _ THEME '=> ", // DEFAULT Template topic name

'Default _ module' => 'home', // DEFAULT MODULE

'Default _ controller' => 'index', // default controller name

'Default _ action' => 'index', // DEFAULT operation name

'Default _ charset' => 'utf-8', // DEFAULT output encoding

'Default _ TIMEZONE '=> 'prc', // DEFAULT time zone

'Default _ AJAX_RETURN '=> 'json', // default ajax data return format, optional json xml...

'Default _ jsonp_handler' => 'jsonprecall', // processing method returned by DEFAULT in JSONP format

'Default _ filter' => 'htmlspecialchars', // The DEFAULT parameter filtering method is used for the I function...

4. ThinkPHP database connection settings

'Db _ type' => ", // Database TYPE. The current databases include Mysql, SqlServer, PgSQL, Sqlite, Oracle, Ibase, and MongoDB.

'Db _ host' => ", // server address

'Db _ name' => ", // database NAME

'Db _ user' => ", // USER name

'Db _ pwd' => ", // password

'Db _ port' => ", // PORT

'Db _ prefix' => ", // database table PREFIX

'Db _ PARAMS '=> array (), // database connection parameters

'Db _ debug' => TRUE, // you can record SQL logs after enabling the database debugging mode.

'Db _ FIELDS_CACHE '=> true, // enable field caching

'Db _ charset' => 'utf8', // The database encoding uses utf8 by default.

'Db _ DEPLOY_TYPE '=> 0, // Database deployment method: 0 centralized (single server), 1 distributed (master/slave server)

'Db _ RW_SEPARATE '=> false, // whether the master-slave mode is valid for database read/write splitting

'Db _ MASTER_NUM '=> 1, // number of master servers after read/write splitting

'Db _ SLAVE_NO '=> ", // specify the serial number of the slave server

5. ThinkPHP data cache settings

'Data _ CACHE_TIME '=> 0, // DATA cache validity period 0 indicates permanent cache

'Data _ CACHE_COMPRESS '=> false, // whether the DATA cache compresses the cache

'Data _ CACHE_CHECK '=> false, // whether the DATA cache verifies the cache

'Data _ cache_prefix' => ", // cache prefix

'Data _ CACHE_TYPE '=> 'File', // DATA cache type, supported: File | Db | Apc | Memcache | Shmop | Sqlite | Xcache | Apachenote | Eaccelerator

'Data _ CACHE_PATH '=> TEMP_PATH, // cache path setting (only valid for File cache)

'Data _ CACHE_KEY '=> ", // cache File KEY (only valid for File caching)

'Data _ cache_subdir' => false, // use sub-directory cache (automatically create sub-directories based on the hash of the cache ID)

'Data _ PATH_LEVEL '=> 1, // sub-directory cache level

6. ThinkPHP error settings

'Error _ message' => 'page ERROR! Please try again later ~ ', // Error display information, not in debug mode

'Error _ page' => ", // ERROR targeting PAGE

'Show _ ERROR_MSG '=> false, // The error message is displayed.

'Trace _ MAX_RECORD '=> 100, // maximum number of error messages at each level

7. ThinkPHP log settings

'Log _ RECORD '=> false, // no logs are recorded by default.

'Log _ type' => 'File', // The default log type is File.

'Log _ level' => 'emerg, ALERT, CRIT, err', // The log level that can be recorded

'Log _ FILE_SIZE '=> 2097152, // LOG file size limit

'Log _ EXCEPTION_RECORD '=> false, // whether to record the exception LOG

8. ThinkPHP template engine settings

'Tmpl _ CONTENT_TYPE '=> 'text/html', // default template output type

'Tmpl _ ACTION_ERROR '=> THINK_PATH. 'tpl/dispatch_jump.tpl', // The default error jumps to the corresponding template file.

'Tmpl _ ACTION_SUCCESS '=> THINK_PATH. 'tpl/dispatch_jump.tpl', // The template file is successfully redirected by default.

'Tmpl _ EXCEPTION_FILE '=> THINK_PATH. 'tpl/think_exception.tpl', // template file of the exception page

'Tmpl _ DETECT_THEME '=> false, // automatically detects the template topic

'Tmpl _ TEMPLATE_SUFFIX '=> '.html', // Default Template File suffix

'Tmpl _ FILE_DEPR '=>'/', // delimiter between the template file CONTROLLER_NAME and ACTION_NAME

9. ThinkPHP layout settings

'Tmpl _ ENGINE_TYPE '=> 'think', // the default template engine. the following settings are only valid for the Think template engine.

'Tmpl _ CACHFILE_SUFFIX '=>'. php', // Default Template cache suffix

'Tmpl _ DENY_FUNC_LIST '=> 'echo, exit', // The template engine disables the function.

'Tmpl _ DENY_PHP '=> false, // whether the default template engine disables PHP native code

'Tmpl _ L_DELIM '=>' {', // template engine common tag start tag

'Tmpl _ R_DELIM '=>'} ', // template engine common tag end tag

'Tmpl _ VAR_IDENTIFY '=> 'array', // template variable identification. If this parameter is left blank, it is automatically judged. if the parameter is 'obj ', it indicates the object.

'Tmpl _ STRIP_SPACE '=> true, // whether to remove html spaces and line breaks in the template file

'Tmpl _ CACHE_ON '=> true, // whether to enable template compilation cache. if it is set to false, the template will be re-compiled every time.

'Tmpl _ cache_prefix' => ", // template cache prefix ID, which can be changed dynamically

'Tmpl _ CACHE_TIME '=> 0, // The template cache validity period 0 is permanent (in numbers, unit: Seconds)

'Tmpl _ LAYOUT_ITEM '=>' {__ CONTENT __} ', // The CONTENT of the layout template replaces the identifier

'Layout _ on' => false, // whether to enable the LAYOUT

'Layout _ name' => 'layout ', // the default layout name is layout.

10. Thinkphp tag library and system variable configuration

// Think template engine tag library settings

'Taglib _ begin' => '<', // tag library label start marking

'Taglib _ end' => ', // tag END tag of the tag library

'Taglib _ load' => true, // whether to use a tag library other than the built-in tag library. it is automatically detected by default.

'Taglib _ BUILD_IN '=> 'cx', // The name of the built-in tag library (you do not need to specify the tag library name for tag use). separate them with commas (,) to note the resolution sequence.

'Taglib _ PRE_LOAD '=> ", // The Tag library to be loaded (the name of the tag library must be specified), separated by commas

/* Set the system variable name */

'Var _ module' => 'm', // The default MODULE obtains the variable.

'Var _ ADDON '=> 'addon', // Default plug-in controller NAMESPACE variable

'Var _ controller' => 'C', // The default CONTROLLER obtains the variable.

'Var _ action' => 'A', // Get the variable by default

'Var _ AJAX_SUBMIT '=> 'Ajax', // Default ajax submission variable

'Var _ jsonp_handler' => 'callback ',

'Var _ pathinfo' =>'s ', // The compatible pattern PATHINFO obtains the variable such? The parameters after s =/module/action/id/1 depend on URL_PATHINFO_DEPR.

'Var _ template' => 'T', // Default TEMPLATE switch variable

'Var _ AUTO_STRING '=> false, // whether the input variable is automatically forcibly converted to a string. If enabled, the array variable needs to be manually passed in to the variable modifier to obtain the variable.

'Http _ CACHE_CONTROL '=> 'private', // webpage cache control

'Check _ APP_DIR '=> true, // CHECK whether the application directory is created

'File _ UPLOAD_TYPE '=> 'local', // FILE Upload method

'Data _ CRYPT_TYPE '=> 'think', // DATA encryption method

11. URL settings

'URL _ CASE_INSENSITIVE '=> true, // The default value is false, indicating that the URL is case-sensitive. true indicates that the URL is case-insensitive.

'URL _ model' => 1, // URL access mode. optional parameters: 0, 1, 2, and 3, which represent the following four modes:

// 0 (normal mode); 1 (PATHINFO mode); 2 (REWRITE mode); 3 (compatible mode): PATHINFO mode by default

'URL _ PATHINFO_DEPR '=>'/', // The delimiter between parameters in PATHINFO mode.

'URL _ PATHINFO_FETCH '=> 'orig _ PATH_INFO, REDIRECT_PATH_INFO, REDIRECT_URL', // list of SERVER substitution variables used for compatibility with PATH_INFO parameter determination

'URL _ REQUEST_URI '=> 'request _ URI', // The default system variable for obtaining the current page address is REQUEST_URI.

'URL _ HTML_SUFFIX '=> 'html', // URL pseudo-static suffix settings

'URL _ DENY_SUFFIX '=> 'ico | png | gif | jpg', // suffix setting for URL-prohibited access

'URL _ params_bind' => true, // bind the URL variable to the Action method parameter

'URL _ PARAMS_BIND_TYPE '=> 0, // type 0 bound to the URL variable binding by variable name binding 1 bound to the variable order

'URL _ params_filter' => false, // URL variable binding filter

'URL _ PARAMS_FILTER_TYPE '=> ", // The DEFAULT_FILTER method is called if the URL variable is null.

'URL _ ROUTER_ON '=> false, // whether to enable URL routing

'URL _ ROUTE_RULES '=> array (), // default routing rules for modules

'URL _ map_rules' => array (), // URL ing definition rules

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.