As a code debugging tool for PHP, By turning on Xdebug's automatic tracing (auto_trace) and analyzer functions, you can directly observe the performance data of the PHP source code, thereby optimizing the PHP code.
Install and configure Xdebug
View the local php version(recommended learning: PHP video Tutorial)
$: php --version PHP 7.0.13-0ubuntu0.16.04.1 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans with Zend OPcache v7.0.13-0ubuntu0.16.04.1, Copyright (c) 1999-2016, by Zend Technologies
Install the Xdebug extension
Go to the official website https://xdebug.org/download.php to download the corresponding version of Xdebug. My operating system is ubuntu16.04, so I downloaded the source version. Xdebug 2.6.0beta1 download link
cd xdebug-source-directory phpize #如果没有,请先安装Php7.0-dev包 which php-config #查找php-config命令的位置 ./configure –with-php-config=/usr/bin/php-config make make install #可能需要加上sudo #安装完了,要记一下xdebug.so的安装位置,下面配置php.ini的时候需要
Configuration php.ini
[Xdebug] zend_extension="/usr/lib/php/20151012/xdebug.so" xdebug.remote_enable=1 #与remote_connect_back不能同时开启 xdebug.remote_host="localhost" xdebug.remote_port=9001 #与remote_host不能同时开启 ;xdebug.remote_connect_back = 1 xdebug.remote_handler="dbgp" xdebug.idekey=PHPSTORM
Explain:
zend_extensionThe location where everyone installs the xdebug extension may be different, depending on the actual situation fill in.
remote_enable must be set to 1
remote_host and remote_port fill in localhost and 9001 respectively. Remote refers to the IDE side, not the browser side or PHP server side. Please understand clearly.
remote_handler can only fill in dbpg, just fill it in as usual.
Idekey is used for session identity identification and needs to be consistent with what is filled in later on the IDE side. What is filled in here is PHPSTORM.
The above is the detailed content of How to check which php execution is slow?. For more information, please follow other related articles on the PHP Chinese website!