In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces PHP Xdebug local and Remote Debugging sample analysis, the article is very detailed, has a certain reference value, interested friends must read!
Local environment:
$ php -vPHP 7.3.4 (cli) (built: Apr 8 2019 10:21:33) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.4, Copyright (c) 1999-2018, by Zend Technologies with Xdebug v2.7.1, Copyright (c) 2002-2019, by Derick Rethans
environment construction
//install xdebug$ pecl install xdebug//configure xdebug$ vim /usr/local/etc/php/7.3/conf.d/extent-xdebug.ini[xdebug] zend_extension="xdebug.so" xdebug.remote_enable=On xdebug.remote_port=9001 xdebug.idekey=PHPSTORM xdebug.remote_connect_back = 1/restart php services $ brew services restart php@7.3
IDE configuration
I put a simple PHP file test.php under the ~/Downloads/xdebug/directory to test. In this directory, I used php -S 127.0.0.1:7790 to start an http service. Please refer to the following configuration.
Several IDEA configuration items
Start listening.
effect demonstration
After setting, hit the breakpoint in the IDE and open this link in the browser to open the test.
http://127.0.0.1:7790/test.php? XDEBUG_SESSION_START=PHPSTORM
The effect is as follows:
It is not necessary to install the Xdebug Helper plugin in your browser.
Remote Debugging
Linkage with the previous article, this article is Remote Debugging, mainly record the process
Local environment:
# php -vPHP 7.2.16 (cli) (built: Mar 10 2019 21:22:49) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Xdebug v2.8.0-dev, Copyright (c) 2002-2019, by Derick Rethans
environment construction
//If you haven't installed it, install # yum install -y php-devel gcc//install xdebug# cd /usr/local/src# git clone https://github.com/xdebug/xdebug.git# cd xdebug# ./ rebuild.sh// xdebug config file # vim /etc/php.d/xdebug. alizend_extension=xdebug.soxdebug.remote_enable=Onxdebug.remote_port=11955xdebug.idekey=PHPSTORM//Restart PHP services # systemctl restart php-fpm# systemctl status php-fpm
Then the key point comes, be sure not to forget to open the xdebug.remote_port port number configured above, open this port number, open this port number, open this port number.
Open ports vary from system to system. In CentOS 7, firewall-cmd can be used to operate.
# firewall-cmd --zone=public --add-port=11955/tcp --permanent# firewall-cmd --reload
IDE configuration
IDE configuration is not the same as local debugging. Generally speaking, there are two ways: one is to configure Remote Debug in IDE, which needs to configure login to remote server; the other is to do remote port forwarding to local through ssh to achieve similar local debugging.
Here, I chose the latter way to operate.
remote port forwarding
// HOST is the configuration host name of the remote server in ~/.ssh/config, which can be replaced with yours such as root@1.1.1ssh-NT -R 11955:127.0.0.1:9001 HOST
This maps remote xdebug port 11955 to local 9001.
IDE configuration
The only difference from the native debug configuration is the host and port, but the rest is similar.
Configuration of IDEA-PHP-Servers:
host is the domain name of the remote web service, and port is the port number of the remote web service.
Also note that: you need to check path mappings, and correctly configure the mapping relationship between the project directory to be debugged in the remote and local environments.
Configuration of IDEA-PHP-XDebug-DBGp-Proxy:
Change host and port to remote web service configuration, same as previous step
effect demonstration
After setting, hit the breakpoint in the IDE and open this link in the browser to open the test.
http://example.com/test.php? XDEBUG_SESSION_START=PHPSTORM
The effect is as follows:
Similarly, it is not necessary for browsers to install the Xdebug Helper plug-in.
The above is "PHP Xdebug local and Remote Debugging Sample Analysis" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.