thinkphp Turn on Debug mode

Source: Internet
Author: User

3.0 version of debug mode on, you must add a constant app_debug definition in the project portal file, as follows:
    1. Define (' App_debug ', True); Turn on debug mode
After you turn on debug mode, you may not feel any change, whether you believe it or not, the debug mode is turned on.
Because the new debug mode does not open the page trace by default (this feature is automatically opened with debug mode in the previous version), the page trace function is now set separately, even if you can open the page trace information display separately in the deployment mode. In short, when you need the page trace information function, the manual configuration is turned on, for example:
    1. ' Show_page_trace ' =>true,
It has nothing to do with whether to turn on debug mode.
So, what are the features of the new debug mode? Let's get this over with. ~ Debug Configuration When it comes to debug mode, you first need to know how to debug the configuration. Although the default Debug configuration file is already available for most situations.
If you turn on debug mode, the system will first load the system default Debug configuration file, located in thinkphp/conf/debug.php, if you do not define the project debug configuration file, debugging mode parameters can refer to the System Debug configuration file settings. The default Debug configuration parameters are as follows:
  1. Return Array (
  2. ' Log_record ' =>true,//logging
  3. ' Log_exception_record ' = true,//whether the Exception log is logged
  4. ' Log_level ' = ' emerg,alert,crit,err,warn,notic,info,debug,sql ',//log level allowed for logging
  5. ' Db_fields_cache ' = false,//field cache information
  6. ' App_file_case ' = true,//check if file capitalization is valid for Windows platform
  7. ' tmpl_cache_on ' = false,//whether to open the template compilation cache, set to False to recompile each time
  8. ' Tmpl_strip_space ' = false,//whether to remove HTML spaces and line breaks inside the template file
  9. ' Show_error_msg ' + true,//Display error message
  10. );
The system Debug configuration is set up in:
    • Turn on logging, any error messages and debugging information will be recorded in detail, easy to debug;
    • Close the template cache, template modification can be effective immediately;
    • Log SQL logs for easy analysis of SQL;
    • Close the field cache, and the data table fields are not affected by the cache;
    • Turn on file case checking (even the Windows platform) to help you discover Linux deployment issues ahead of time;
The purpose of debug mode is to make it easier to find, record, analyze and resolve errors, and in the deployment mode, there may be many potential errors you can not find, these errors are like a time bomb, there are hidden dangers.
If you feel that the system default Debug configuration does not meet your needs, such as you want to turn on the page trace information display, you can increase the project Debug configuration file, for example:
    1. Return Array (
    2. ' Show_page_trace ' = True,//Display page TRACE information
    3. );
In the project Debug configuration file, you only need to add parameters that are different from the System debug profile (add or modify) and then save to the project's conf/debug.php.
Once the project has turned off debug mode, the Debug configuration file (including the system Debug configuration file and the project debug profile) is invalidated and all parameters in the Debug configuration file will no longer work. At the same time, the system runs in accordance with the custom configuration file and the parameter configuration in the project configuration file, so you should know how to differentiate between using the project configuration file and the project Debug configuration file. Debug state Application Debug state is a new version of the concept, the role of debugging mode in the state, you can set the project different application state, and automatically load different project configuration files. Can be thought of as a few stages in the project development process, especially when these phases require simultaneous or cross-running, such as a development team wishing to have its own debug database and debugging information, and the Test team wants a clean test environment, you do not want to always change the project configuration file or debug the configuration file. You can then set different application debug states for different stages and define different profiles separately.
The change to apply debug state is by setting the App_status parameter, the default parameter setting is debug, if you want to increase the application state under Debug mode, such as Test status, you can change the settings in the project configuration file as follows:
    1. ' App_status ' = ' test ',//apply debug mode state
In this case, the system will automatically attempt to load the test.php configuration file under the project configuration directory to change the settings in the test configuration file, such as changing the connection information of the testing database and so on. Summary Typically, the debug configuration file can be used for some development phase or the configuration required for testing. For example, configure additional database connections for debugging, turn on log writing to find error messages, turn on page trace output for more debugging information, and so on, all of which will fail once the debug mode is turned off.
Because debug mode does not have any caches, it involves a lot of file IO operations and template real-time compilation, so when debugging mode is turned on, performance will decrease, but it will not affect the performance of the deployment mode.

thinkphp Turn on Debug mode

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.