search
HomeBackend DevelopmentPHP TutorialSummary of common configuration options of ThinkPHP, thinkphp configuration options_PHP tutorial

A summary of common configuration options of ThinkPHP, thinkphp configuration options

This article describes the common configuration options of ThinkPHP with examples. Share it with everyone for your reference, the details are as follows:

return array(
  /* Dispatch设置 */
  'DISPATCH_ON' => true, // 是否启用Dispatcher
  // URL模式: 0 普通模式 1 PATHINFO 2 REWRITE 3 兼容模式 当DISPATCH_ON开启后有效
  'URL_MODEL' => 1, // 默认为PATHINFO 模式,提供最好的用户体验和SEO支持
  // PATHINFO 模式
  // 普通模式1 参数没有顺序/m/module/a/action/id/1
  // 智能模式2 自动识别模块和操作/module/action/id/1/ 或者 /module,action,id,1/...
  // 兼容模式3 通过一个GET变量将PATHINFO传递给dispather,默认为s index.php?s=/module/action/id/1
  'PATH_MODEL' => 2, // 默认采用智能模式
  'PATH_DEPR' => '/', // PATHINFO参数之间分割号
  'ROUTER_ON' => false, // 是否开启URL路由
  'CHECK_FILE_CASE' => false, // 是否检查文件的大小写 对Windows平台有效
  'TAG_PLUGIN_ON' => false, // 是否开启插件机制
  'SESSION_AUTO_START' => true, // 是否自动开启Session
  /* 日志设置 */
  'WEB_LOG_RECORD' => false, // 默认不记录日志
  'LOG_RECORD_LEVEL' => array('EMERG','ALERT','CRIT','ERR'), // 允许记录的日志级别
  'LOG_FILE_SIZE' => 2097152, // 日志文件大小限制
  /* 错误设置 */
  'DEBUG_MODE' => false, // 调试模式默认关闭
  'ERROR_MESSAGE' => '您浏览的页面暂时发生了错误!请稍后再试~', // 错误显示信息 非调试模式有效
  'ERROR_PAGE' => '', // 错误定向页面
  'SHOW_ERROR_MSG' => true,
  /* 系统变量设置 */
  'VAR_PATHINFO' => 's', // PATHINFO 兼容模式获取变量例如 ?s=/module/action/id/1 后面的参数取决于PATH_MODEL 和 PATH_DEPR
  'VAR_MODULE' => 'm', // 默认模块获取变量
  'VAR_ACTION' => 'a', // 默认操作获取变量
  'VAR_PAGE' => 'p', // 默认分页跳转变量
  'VAR_TEMPLATE' => 't', // 默认模板切换变量
  'VAR_LANGUAGE' => 'l', // 默认语言切换变量
  'VAR_AJAX_SUBMIT' => 'ajax', // 默认的AJAX提交变量
  /* 模块和操作设置 */
  'DEFAULT_MODULE' => 'Index', // 默认模块名称
  'DEFAULT_ACTION' => 'index', // 默认操作名称
  /* 模板设置 */
  'TMPL_CACHE_ON' => true, // 默认开启模板编译缓存 false 的话每次都重新编译模板
  'TMPL_CACHE_TIME' => -1, // 模板缓存有效期 -1 永久 单位为秒
  'TMPL_SWITCH_ON' => true, // 启用多模版支持
  'AUTO_DETECT_THEME' => false, // 自动侦测模板主题
  'DEFAULT_TEMPLATE' => 'default', // 默认模板名称
  'TEMPLATE_SUFFIX' => '.html', // 默认模板文件后缀
  'CACHFILE_SUFFIX' => '.php', // 默认模板缓存后缀
  'OUTPUT_CHARSET' => 'utf-8', // 默认输出编码
  'TMPL_VAR_IDENTIFY' => 'array', // 模板变量识别 留空自动判断 array 数组 obj 对象
  /* 分页设置 */
  'PAGE_NUMBERS' => 5, // 分页显示页数
  'LIST_NUMBERS' => 20, // 分页每页显示记录数
  /* 模型设置 */
  'AUTO_NAME_IDENTIFY' => true, // 模型对应数据表名称智能识别 UserType => user_type
  'DEFAULT_MODEL_APP' => '@', // 默认模型类所在的项目名称 @ 表示当前项目
  /* 静态缓存设置 */
  'HTML_FILE_SUFFIX' => '.shtml', // 默认静态文件后缀
  'HTML_CACHE_ON' => false, // 默认关闭静态缓存
  'HTML_CACHE_TIME' => 60, // 静态缓存有效期
  'HTML_READ_TYPE' => 1, // 静态缓存读取方式 0 readfile 1 redirect
  'HTML_URL_SUFFIX' => '', // 伪静态后缀设置
  /* 语言时区设置 */
  'TIME_ZONE' => 'PRC', // 默认时区
  'LANG_SWITCH_ON' => false, // 默认关闭多语言包功能
  'DEFAULT_LANGUAGE' => 'zh-cn', // 默认语言
  'AUTO_DETECT_LANG' => false, // 自动侦测语言
  /* 数据库设置 */
  'DB_CHARSET' => 'utf8', // 数据库编码默认采用utf8
  'DB_DEPLOY_TYPE'      => 0,     // 数据库部署方式 0 集中式(单一服务器) 1 分布式(主从服务器)
  'DB_RW_SEPARATE' => false,
  'DB_FIELDS_CACHE' => true,
  /* 数据缓存设置 */
  'DATA_CACHE_TIME' => -1, // 数据缓存有效期
  'DATA_CACHE_COMPRESS' => false, // 数据缓存是否压缩缓存
  'DATA_CACHE_CHECK' => false, // 数据缓存是否校验缓存
  'DATA_CACHE_TYPE' => 'File', // 数据缓存类型 支持 File Db Apc Memcache Shmop Sqlite Xcache Apachenote Eaccelerator
  'DATA_CACHE_PATH' => TEMP_PATH, // 缓存路径设置 (仅对File方式缓存有效)
  'DATA_CACHE_SUBDIR' => false, // 使用子目录缓存 (自动根据缓存标识的哈希创建子目录)
  'DATA_PATH_LEVEL' => 1, // 子目录缓存级别
  'CACHE_SERIAL_HEADER' => "<&#63;php\n//", // 文件缓存开始标记
  'CACHE_SERIAL_FOOTER' => "\n&#63;".">", // 文件缓存结束标记
  /* 运行时间设置 */
  'SHOW_RUN_TIME' => false, // 运行时间显示
  'SHOW_ADV_TIME' => false, // 显示详细的运行时间
  'SHOW_DB_TIMES' => false, // 显示数据库查询和写入次数
  'SHOW_CACHE_TIMES' => false, // 显示缓存操作次数
  'SHOW_USE_MEM' => false, // 显示内存开销
  'SHOW_PAGE_TRACE' => false, // 显示页面Trace信息 由Trace文件定义和Action操作赋值
  /* 模板引擎设置 */
  'TMPL_ENGINE_TYPE' => 'Think', // 默认模板引擎 以下设置仅对使用Think模板引擎有效
  'TMPL_DENY_FUNC_LIST' => 'echo,exit', // 模板引擎禁用函数
  'TMPL_L_DELIM' => '{', // 模板引擎普通标签开始标记
  'TMPL_R_DELIM' => '}', // 模板引擎普通标签结束标记
  'TAGLIB_BEGIN' => '<', // 标签库标签开始标记
  'TAGLIB_END' => '>', // 标签库标签结束标记
  'TAG_NESTED_LEVEL' => 3, // 标签库
  'TAGLIB_LIST' => 'cx,html', // 内置标签库名称
  /* Cookie设置 */
  'COOKIE_EXPIRE' => 3600, // Coodie有效期
  'COOKIE_DOMAIN' => '', // Cookie有效域名
  'COOKIE_PATH' => '/', // Cookie路径
  'COOKIE_PREFIX' => '', // Cookie前缀 避免冲突
  /* 数据格式设置 */
  'AJAX_RETURN_TYPE' => 'JSON', //AJAX 数据返回格式 JSON XML ...
  /* 其它设置 */
  'AUTO_LOAD_PATH' => 'Think.Util.', // __autoLoad 的路径设置 当前项目的Model和Action类会自动加载,无需设置 注意搜索顺序
  'ACTION_JUMP_TMPL'=> 'Public:success', // 页面跳转的模板文件
  'ACTION_404_TMPL'=> 'Public:404', // 404错误的模板文件
  'APP_DOMAIN_DEPLOY' => false, // 是否使用独立域名部署项目
  /* 需要加载的外部配置文件 */
  'EXTEND_CONFIG_LIST'=>array('taglibs','routes','tags','htmls','modules','actions'),
  // 内置可选配置包括:taglibs 标签库定义 routes 路由定义 tags 标签定义 htmls 静态缓存定义 modules 扩展模块 actions 扩展操作
);

Readers who are interested in more thinkPHP-related content can check out the special topics on this site: "ThinkPHP Getting Started Tutorial", "ThinkPHP Common Methods Summary", "Smarty Template Basic Tutorial" and "PHP Template Technology Summary".

I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.

Articles you may be interested in:

  • Analysis of ThinkPHP project grouping configuration method
  • Nginx configuration supports ThinkPHP’s PATH_INFO
  • Nginx supports Thinkphp URL Rewrite Configuration example
  • THINKPHP supports YAML configuration file setting method
  • thinkPHP study notes installation and configuration article
  • thinkphp configuration connection database skills
  • thinkphp URL routing Rules and configuration examples
  • Methods for combining ThinkPHP public configuration files with configuration files in respective projects
  • Mapping analysis of public function paths and configuration item paths in ThinkPHP
  • ThinkPHP convention configuration Detailed file explanation
  • Configure pathinfo mode in nginx to support thinkphp URL rewriting
  • Modify the apache configuration file to remove index.php in thinkphp url
  • Parse thinkphp basic configuration convention. php

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1113700.htmlTechArticleA summary of common configuration options of ThinkPHP, thinkphp configuration options This article describes the common configuration options of ThinkPHP with examples. Share it with everyone for your reference, the details are as follows: return array( /* Di...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP: An Introduction to the Server-Side Scripting LanguagePHP: An Introduction to the Server-Side Scripting LanguageApr 16, 2025 am 12:18 AM

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP and the Web: Exploring its Long-Term ImpactPHP and the Web: Exploring its Long-Term ImpactApr 16, 2025 am 12:17 AM

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.

Why Use PHP? Advantages and Benefits ExplainedWhy Use PHP? Advantages and Benefits ExplainedApr 16, 2025 am 12:16 AM

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

Debunking the Myths: Is PHP Really a Dead Language?Debunking the Myths: Is PHP Really a Dead Language?Apr 16, 2025 am 12:15 AM

PHP is not dead. 1) The PHP community actively solves performance and security issues, and PHP7.x improves performance. 2) PHP is suitable for modern web development and is widely used in large websites. 3) PHP is easy to learn and the server performs well, but the type system is not as strict as static languages. 4) PHP is still important in the fields of content management and e-commerce, and the ecosystem continues to evolve. 5) Optimize performance through OPcache and APC, and use OOP and design patterns to improve code quality.

The PHP vs. Python Debate: Which is Better?The PHP vs. Python Debate: Which is Better?Apr 16, 2025 am 12:03 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on the project requirements. 1) PHP is suitable for web development, easy to learn, rich community resources, but the syntax is not modern enough, and performance and security need to be paid attention to. 2) Python is suitable for data science and machine learning, with concise syntax and easy to learn, but there are bottlenecks in execution speed and memory management.

PHP's Purpose: Building Dynamic WebsitesPHP's Purpose: Building Dynamic WebsitesApr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP: Handling Databases and Server-Side LogicPHP: Handling Databases and Server-Side LogicApr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

How do you prevent SQL Injection in PHP? (Prepared statements, PDO)How do you prevent SQL Injection in PHP? (Prepared statements, PDO)Apr 15, 2025 am 12:15 AM

Using preprocessing statements and PDO in PHP can effectively prevent SQL injection attacks. 1) Use PDO to connect to the database and set the error mode. 2) Create preprocessing statements through the prepare method and pass data using placeholders and execute methods. 3) Process query results and ensure the security and performance of the code.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor