To debug code for phpstorm configuration Xdebug

Source: Internet
Author: User
Tags php debug phpinfo zts zend

When projects become more complex, it becomes more difficult to make mistakes.
You think the code works this way, but it's the unpredictable functionality that makes the process elusive.
At this time we need debugging AH debugging ...

Phpstorm is a good PHP IDE, excluding its Java system origin caused by the resource consumption is not ideal, its functionality and ease of use is beyond question.
Well, the next is the soft text.

Phpstorm built Zend Debugger and Xdebug support, we can start debugging code with a simple configuration. Let's take Xdebug as an example to illustrate. installing Xdebug extensions for PHP

Win under the installation is simpler, directly download the appropriate version of the DLL file, written to the php.ini configuration can be.
We introduce the source code to compile the way.

Find the latest source code on the Xdebug download page, now in version 2.2.1:

cd/users/micate/downloads/
wget http://xdebug.org/files/xdebug-2.2.1.tgz
tar zxvf xdebug-2.2.1.tgz
CD XDEBUG-2.2.1/
phpize
./configure make
sudo make install

Well, not surprisingly, will prompt xdebug.so has been placed in ... Position. Remember this position, copy it down.

Open PHP.ini and append the following configuration to the last side:

[Xdebug]
zend_extension= "/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.idekey= "PHPSTORM"
xdebug.remote_host=127.0.0.1
Xdebug.remote_enable=on

The position above is consistent with the location you just installed. Instructions on how to configure xdebug.so are described in the Xdebug documentation:

Configure PHP to use Xdebug add the following line to Php.ini:zend_extension= "/wherever/you/put/it/xdebug.so" (for Non-t hreaded use of PHP, for example the CLI, CGI or Apache 1.3 module) or:zend_extension_ts= "/wherever/you/put/it/xdebug.so" (For threaded usage of PHP, for example the Apache 2 work MPM or the ISAPI module). Note:in Case for you compiled PHP yourself and used--enable-debug your would to use have. From PHP 5.3 onwards, your always need to use the zend_extension php.ini name, and not setting, zend_extension_ts nor Extension_debug. However, your compile options (zts/normal build; debug/non-debug) still need to match with what the PHP is using. Restart your webserver. Write a PHP page that calls ' phpinfo () ' "Load it in a browser and look for the" info on the Xdebug module. If you are the it next to the Zend logos, you have been successful! can also use ' php-m ' if your have a command line version of PHP, it lists all loaded modules. Xdebug should appear Twice there (once under ' PHP Modules ' and once ' under Zend ').

The use of zend_extension_ts or zend_extension or god horse God horse, and PHP version, carefully read the instructions above.

Restart the Web Server (Apache/nginx) and use the Phpinfo () page or command-line tool to confirm that the module is installed. Configure Phpstorm

This section refers to the configuring PHP debugging in Phpstorm 2.0 article:

Phpstorm with the latest version of 4.0.3, for example, there are some differences in the version.

Open Phpstorm, create or open a project, and open the Preferences interface:

As shown, verify that debug settings are correct (prompt, you can search for debug directly in the upper-left corner to locate the setup item):

Click Servers on the left to add a Debug Server:

where Host and Port according to their own to debug the actual situation to write, do not add a directory or query string. Select Xdebug later.
Then Apply and OK, back to the editor interface.

Click on the run-configurations in the menu:

In the Run/Debug dialog box, configure it according to the diagram:

As shown in the picture: Click the Add button, select the PHP Web application, and enter the configuration name on the right, select the Server,start URL we just added to fill out the necessary query string for debugging, choose a good default browser, and finally click Apply and OK, confirm the configuration.

And then, there's one more step:
Set breakpoints in the program, in the toolbar, select the application to debug, click the Start Listen PHP Debug Connections button, that is, the red phone button to turn green, that is, start listening to PHP debug connection;

So, finally can begin.
Click on the Debug button in the image above, or choose Run-debug from the menu, and you start the debug trip ... Other Notes

Depending on the breakpoint configuration, or when the debug URL is opened, or after POST, if Phpstorm hears the debug connection, it immediately switches to the editor interface and jumps to the set breakpoint, and the browser side waits for the phpstorm operation.

You can interrupt Phpstorm debugging at any time, or facilitate the step Into/step over/run to Cursor (this explosive):

Familiar with Java children's shoes will be friendly to this interface, Roar.

Alas, do not want to debug, phpstorm but always jump out. Remember just that phone button, and then click, let it become red, just fine.

Get here first, huh? Beat the drums yourself. This entry is posted in sharing and tagged PHP, phpstorm, Xdebug on July 29, 2012. Post Navigation ← Install the PHP memcache extension on OS X 10.7/10.8 to compile installation support under OS X Http/https subversion→ 9 thought s on "Configure Xdebug for Phpstorm to debug code"

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.