Phpstorm+xdebug remotely debugging code on a Linux machine

Source: Internet
Author: User

First, Background introduction :

Recently in understanding the site navigation project, in order to be able to understand the object under test, so I chose to look at the URL navigation code to do, but just hard to see the PHP source code is relatively jerky, I want to be able to through the IDE Tool to step through the code to understand the entire URL navigation function implementation.

To achieve these goals, I chose phpstorm+xdebug to remotely debug the code on Linux . And before the white Pine sharing phpstorm+xdebug debugging method is different, the former debug Webserver is in the local environment set up Php+apache debugging, and I have to face the problems are:

1. The code for the URL navigation is deployed on the Linux virtual machine environment.

2. the Code Runtime Environment is:linux+nginx+php-fpm+redis+superphp Environment support

In order to solve the above methods, the following methods are adopted.

Second, the configuration method :

1. compiling the configuration on the Linux virtual machine xdebug

1) Download xdebug. To access http://xdebug.org/download.php, download the corresponding xdebug source code.

2) # TAR-XVF xdebug-2.3.2.tgz

3) #cd Xdebug

4) Run the php directory /bin/phpize

5) Configure the bin path for the ./configure--enable-xdebug--with-php-config=/php /php-config

6) Make

7) make install

2. Configuring Xdebug on a Linux virtual machine

Add the following configuration in the php.ini file:

zend_extension= " /search/php5/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so "//xdebug.so path, please configure it according to the installed PHP directory

[Xdebug]

Xdebug.idekey=phpstorm

xdebug.remote_connect_back = 1 // If this is turned on, the following xdebug.remote_host parameters will be ignored

xdebug.remote_host= 10.129.157.29 // Note here is that the client's ip< is the IP of the IDE 's machine , not your web server>

Xdebug.remote_enable=on

Xdebug.remote_port = 9001  // Note here is that the port of the client < that IDE the machine's IP, It's not yours. Web server>

Xdebug.remote_handler = DBGP

Xdebug.auto_trace = 1

Xdebug.collect_includes = 1

Xdebug.collect_params = 1

Xdebug.collect_return = 1

xdebug.default_enable = 1

Xdebug.collect_assignments = 1

Xdebug.collect_vars = 1

Xdebug.remote_autostart = 1

Xdebug.show_local_vars = 1

Xdebug.show_exception_trace = 0

3. Download phpstorm

4. Configuring in phpstorm

1) Configure Debug Entry: Open file->setings->php| Debug. In the Xdebug configuration item on the right, configure the same port number as the server Xdebug, as in the example above 9001.

2) Configure the server item .

A. Open file->setings->php| Servers on the right click +, add server,host:web server domain name or IP, the port is generally 80.

B. tick the use pathmappingbelow to fill in the path to the server where the code is located on the absolute path to the server. It must be set here! Otherwise, a file cannot be found and an error occurs, which leads to the debug termination.

Note: since the URL is also referenced in the navigation superphp , so in Project the need to increase superphp , and set up on the server superphp the path.

3) Configure the Web application Pilot : Open run->editconfigurations-> to add a PHP webapplication to the tuning pilot.

At this point, the configuration is complete!

5. After setting a breakpoint in the code, click Run->debug, the browser is called, and the breakpoint in the Phpstorm is interrupted, then you can F5 one step debugging.

Phpstorm+xdebug remotely debugging code on a Linux machine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.