This article we have a comprehensive understanding of how to thinkphphttp://www.aliyun.com/zixun/aggregation/17799.html "" > development process debugging work.
Debug mode
When it comes to debugging, we may be the first to think of debugging mode, yes, thinkphp also has a special set for the development process of debugging mode, thinkphp debug mode is different, will sacrifice a certain degree of implementation efficiency, but bring convenience and debugging function is very worthwhile. We strongly recommend that thinkphp developers always turn on debug mode at the development stage (until after formal deployment to turn off debug mode) to facilitate timely discovery of hidden problems and analysis and resolution of problems.
Opening debug mode is simple, just add one line of constant definition code to the entry file:
<?php//Open Debug mode define (' App_debug ', true); Load frame entry file require './thinkphp/thinkphp.php ';
After the development phase is deployed to the production environment, only the debug mode definition code needs to be removed to switch to deployment mode. The advantage of Debugging mode is: Open log record, any error information and debug information will be recorded in detail, easy to debug;
Turning off the template cache, template modifications can take effect immediately, log SQL logs, facilitate analysis of SQL, turn off field caching, data table fields are not affected by caching, and rigorously check file capitalization (even on Windows platforms) to help you identify Linux deployment issues in advance; Can be easily used in different stages of the development process, including any requirements such as development, testing, and presentation, and different application modes can be configured with separate project profiles;
In the state where debug mode is turned on, we can set up different application states for the project and load different project profiles, but in any case, the framework default debug mode configuration file is imported first, which is located in the system directory conf\debug.php.
Typically, there are configurations in the Debug configuration file that you need to develop patterns. For example, configuring additional database connections for debugging, opening log writes facilitates finding error messages, opening page trace output more debugging information, and more.
If the application state is not configured, the system defaults to debug state by default, which means the default configuration parameters are:
' App_status ' => ' Debug ',//apply debug mode state
If a debug.php file is detected in the project's configuration directory, the profile is automatically loaded and merged with the System project configuration file and the system debug profile, that is, the debug.php configuration file requires only configuration and project configuration files and different parameters or new parameters for the system Debug configuration file. If you want to increase the application state, such as the test status, under Debug mode, you can change the settings in the project configuration file as follows:
' App_status ' => ' test ',//apply debug mode state
In this case, the system will automatically try to load the test.php configuration file under the project configuration directory, and you can change the relevant settings in the test configuration file, such as changing the connection information of the testing database, and so on.
Since debug mode does not have any caching, so it involves more file IO operations and template real-time compilation, so in the case of open debug mode, performance will have a certain decline, but does not affect the performance of the deployment mode. Also note that once debug mode is turned off, the Debug configuration file for the project is immediately invalidated.