Debugging PHP code in Phpstorm

Source: Internet
Author: User
Tags php debug

It is very inefficient to debug PHP with the variable output by Echo,var_dump,print_r and so on. With Xdebug, you can debug PHP directly in the IDE.

Installing XdebugDownload Xdebug

Please download the corresponding PHP version of Xdebug

1 2 3 wget wget http: //xdebug .org /files/xdebug-2 .2.1.tgz tar xzvf xdebug-2.2.1.tgz cd xdebug-2.2.1
Installing XDEUBG
1 2 3 4 /usr/local/webserver/php/bin/phpize . /configure -- enable -xdebug --with-php-config= /usr/local/webserver/php/bin/php-config make cp modules /xdebug .so /usr/local/webserver/php/lib/php/extensions/

Modifications php.ini , vi /usr/local/webserver/php/etc/php.ini

At the bottom, add the following:

1 2 3 4 5 6 7 8 [XDEBUG] zend_extension= "/usr/local/webserver/php/lib/php/extensions/xdebug.so" xdebug.remote_enable=on ; 此地址为IDE所在IP xdebug.remote_host=xxx.xxx.xxx.xxx xdebug.remote_port=9000 ; 可以是任意Key,这里设定为PHPSTORM xdebug.idekey= "PHPSTORM"
Configure the IDE

I'm using the IDE is Phpstorm, so the following configurations are based on Phpstorm, others like Netbean and ECLIPCE

Inside the settings, select PHP---Debug, fill in the Xdebug just set the port, OK.

When set, click Run, start Listen PHP Debug Connections to turn on monitoring.

Configure the browser

The Firefox browser installs easy Xdebug and installs Xdebug helper on Chrome. After installation, IDE Key fill in PHPSTORM (need and configuration) can be.

Start Debug

After the setup is complete, add the appropriate breakpoint in the Phpstorm and then use the newly configured browser to access the page, and the first time you open Phpstorm will prompt to receive a connection from the server where PHP is located. For example, the debugger window already has debug information:

Debugging PHP code 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.