Home> PHP Framework> ThinkPHP> body text

How to turn off info information output in thinkphp5

王林
Release: 2023-06-03 11:49:08
forward
1286 people have browsed it

1. The role of info

Before we start to close info, we need to understand its role. In the ThinkPHP5 framework, there are three main forms of info information output:

  1. Displays the currently accessed URL and request parameters

  2. Displays the current URL at the bottom of the page Debugging information such as the page's SQL statement execution and running time

  3. When an execution error occurs, detailed error information is output to facilitate debugging

Although It seems helpful, but for real developers, most of the info information is not very practical. Often, what we need is some more concise output so we can better focus on development.

2. Close info

Close info is very simple. You only need to set the app_debug configuration item to false in app.php in the configuration file to close info. Information output. The sample code is as follows:

return [ 'app_debug' => false ];
Copy after login

After this setting, by default, the page will no longer display the current URL and request parameters, and will not output SQL statement execution status and error information. Of course, you can turn info back on in the framework's debug mode if you need to.

In addition, if you need to output the SQL execution status for debugging during the development process, you can turn on the SQL log as follows:

Db::listen(function($sql, $time, $explain){ // 记录SQL trace($sql . ' [' . $time . 's]', 'sql'); // 查看性能分析结果 trace($explain, 'explain'); });
Copy after login

In this way, you can output SQL in the trace folder of the program Log information.

The above is the detailed content of How to turn off info information output in thinkphp5. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!