Configuring the Xdebug Debug Environment in Phpstorm

Source: Internet
Author: User

1. Installing Xdebug

First step: Get local PHP configuration information

Running in Terminal: Php-i > Outputphp.txt

The information in the resulting TXT file is then copied to a textarea provided in the http://xdebug.org/wizard.php page. Then click on the Analyze button below, it will automatically help you to resolve your local PHP environment information to get the Xdebug version you need to download and related configuration instructions.

For the following steps, you will also need to install the Php5-dev dependency package:

sudo apt-get install php5-dev
    • 1

Step two: Get the version and related instructions you need to download

For example, I get the following information:

    1. Download xdebug-2.3.2.tgz (directly click on the generated link)
    2. Unzip the file:tar -xvzf xdebug-2.3.2.tgz
    3. Run:cd xdebug-2.3.2
    4. Run: See the FAQs If you don't have phpize ( phpize.
      Some of the output is as follows:
      Configuring for:
      ...
      Zend Module Api no:20121212
      Zend Extension Api no:220121212
      If you do not have the above output, then there is a problem representing your phpize. Refer to FAQ.

    5. Run:./configure

    6. Run:make
    7. Run:sudo cp modules/xdebug.so /usr/lib/php5/20121212

Some of these steps may require sudo.

Step three: Add configuration items to PHP.ini

sudo vim /etc/php5/cli/php.inizend_extension = /usr/lib/php5/20121212/xdebug.soxdebug.remote_host = 127.0.0.1xdebug.remote_enable = 1xdebug.remote_port = 9000xdebug.remote_handler = dbgpxdebug.remote_mode = req
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

If not necessary, the above configuration items do not need to be modified. I just took it for granted. The Remote_port was modified to be the port number of my application on the server, resulting in the inability to debug. It took a while to locate the problem here.

Here, Xdebug is installed successfully. Can be verified by the php–version command:

PHP 5.5.9-1ubuntu4.7 (CLI) (Built:mar 20:47:39) Copyright
(c) 1997-2014 the PHP Group Zend Engine v2.5.0, Copyright (c)
1998-2014 Zend Technologies
With Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans
With Zend Opcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

You can see that the Xdebug information already exists in the output.

2. Installing Xdebug Extension Helper

In the mainstream browser has xdebug extension helper plug-in, can help you open or close the debugging function conveniently, why the need for this plug-in, you can refer to this article in the 4, 5, 6 bars (English, interested students can check their own)

For example, in Chrome, find the installation address for the plugin here:
https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en
If not open, you can refer to this article, how to use the ID of the plug-in offline download, after all, Google's services are now fully wall ...

The plugin ID for the Xdebug Helper is: EADNDFJPLGIELDJBIGJAKMDGKMOAAAOC

After the installation is complete, open the options for the plugin and set Idekey to Phpstorm.

3. Configure Phpstorm

Finally to the last step, this step is very simple.
Just tick the Start Listening for PHP Debug Connectionsunder the Run menu.

Then make a breakpoint where you need to debug, and finally enter the address of the PHP script in the browser. Note To enable Xdebug Helper that was previously installed.
The methods that are enabled are:

OK, let's be happy to debug!!!

Principles (quoted from Xdebug's official website)

Main reference articles:

Https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm
http://icephoenix.us/php/how-to-setup-local-php-debugging-with-phpstorm-and-xdebug/
Http://xdebug.org/docs/remote#starting

Configuring the Xdebug Debug Environment in Phpstorm

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.