Current Location: Home> Latest Articles> How to Disable Debugging Information Output in ThinkPHP5

How to Disable Debugging Information Output in ThinkPHP5

gitbox 2025-06-25

1. Enable Debug Mode

By default, ThinkPHP5 will display debugging information at the bottom of the page, including runtime, memory consumption, and more. If you want to disable this output, the first step is to turn off the framework's debug mode.

In the ThinkPHP5 configuration file (located in the config folder in the project root directory), find the app.php file and set the value of app_debug to false, as shown below:


// Disable debug mode
'app_debug'              => false,

2. Disable Trace Information Output

In addition to the debug mode output, ThinkPHP5 also provides trace information, which includes controller, method, request parameters, and more. If you want to disable trace information output, follow these steps:

In the same app.php configuration file, find the trace configuration item and set its value to false, as shown below:


// Disable trace information output
'trace'                  => false,

3. Disable Log Information Output

ThinkPHP5 automatically records various operation logs to assist with debugging. If you do not want these log outputs to appear on the page, you can disable them as follows:

In the app.php file, find the log' => [] configuration item and set its value to an empty array [], as shown below:


// Disable log information output
'log'                    => [],

4. Disable Exception Information Output

When an exception occurs, ThinkPHP5 will by default output the error message and stack trace information on the page. If you do not want to see this information, you can configure the following in the app.php file:

Find the show_error_msg configuration item and set its value to false, as shown below:


// Disable exception information output
'show_error_msg'         => false,

5. Disable SQL Query Output

ThinkPHP5 by default outputs the SQL queries that are executed, which is useful for debugging and analysis. If you want to disable the SQL output, you can do so as follows:

In the app.php file, find the sql_explain' => false configuration item and set its value to false, as shown below:


// Disable SQL query output
'sql_explain'            => false,

6. Fine-Tuning Information Output

In addition to the global configurations mentioned above, ThinkPHP5 provides some detailed settings to help you control the information output more precisely. For example, you can configure whether to display detailed template rendering information or file loading information.

In the app.php file, you can find configuration items starting with detail_, such as detail_tpl_replace, detail_file_load, etc. You can modify these values to false to disable the related information output.

Conclusion

With the configurations above, you can disable various debugging information outputs in the ThinkPHP5 framework, including debug mode, trace information, log information, exception information, and SQL query output. This will help improve system performance and enhance security in production environments.

Note that disabling this information is only suitable for production environments. In a development environment, it is recommended to set the relevant configuration items to true for easier debugging and troubleshooting.