Install and configure xdebug in PHPstorm _ PHP Tutorial

Source: Internet
Author: User
Tags php debug what php zts
Install and configure xdebug in PHPstorm. This article introduces the xdebug installation and configuration instructions in PHPstorm. this is not the first time I configured PHPstorm. I will share my experience with you below. It is not the first time to configure xdebug, but this article will introduce the xdebug installation and configuration instructions in PHPstorm. this is not the first time I configured PHPstorm. I will share my experience with you below.

Xdebug with phpstorm is not the first time, but xdebug with phpstorm is the first time (self-recognition and error correction capabilities are strong, and the familiarity with the framework is fast, if you know where the problem file is located and fix the code directly, you do not need to use xdebug + IDE for debugging ). I have never had time to make fun of IDE-level things since I took part in my new job in March. today, I have finally got a little free time to play ~

The installation and configuration of xdebug is a common topic. here we will not describe the method and process of installing xdebug. we will only explain the configuration requirements of xdebug in the php. ini file required by phpstorm.


Php. ini configuration
"[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
Xdebug. remote_port = 9000
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. remote_connect_back = 1
Xdebug. show_local_vars = 1
Xdebug. show_exception_trace = 0

"How to configure xdebug. so is described in the Xdebug document:

"Configure PHP to Use Xdebug

Add the following line to php. ini: zend_extension = "/wherever/you/put/it/xdebug. so "(for non-threaded 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 you compiled PHP yourself and used-enable-debug you wowould have to use zend_extension_debug =. from PHP 5.3 onwards, you always need to use the zend_extension PHP. ini setting name, and not zend_extension_ts, nor zend_extension_debug. however, your compile options (ZTS/normal build; debug/non-debug) still need to match with what PHP is using.

Restart your webserver.
Write a PHP page that call'phpinfo () 'Load it in a browser and look for the info on the Xdebug module. if you see it next to the Zend logo, you have been successful! You can also use 'php-M' if you have a command line version of php, it lists all loaded modules. xdebug shoshould appear twice there (once under 'php modes' and once under 'zend modes ').

"Whether to use zend_extension_ts, zend_extension, or Shenma is related to the PHP version. read the preceding instructions carefully.

Restart the Web Server (Apache/Nginx) and use the phpinfo () page or command line tool to confirm that the module installation is complete.

Phpstorm configuration


I use phpstorm5.0.4. it doesn't matter even if it is earlier. the configuration method described in this tutorial is 4.0 ~ 5. the + version is common.

1. file> Settings, PHP | Server: click the + symbol. enter the Name you specify for the Server in the Name column, and enter the address of the debugging Server in the Host column, without the need for "http:. In the Port column, enter the server product (usually the default value is 80), and in the Debugger column, select Xebug.

Select Xebug in the "Debugger" column.

2. File> Settings, PHP | Debug. in the Xdebug label box, configure the Debug port based on the Xdebug port on the server, and configure other parameters as needed.

3. click Use debugger bookmarklets to initiate debugging from your favorite browser to configure the debugger bookmarks in the default browser of the system.

4. open the browser by default and go to http://www.jetbrains.com/phpstorm/marklets/. modify the IDE key under xebug. the default value is PHPSTORM.

5. click Generate in the Xdebug column and add the Xdebug group to the bookmarks of the browser. each item of Xdebugger exists.

6. return to PHPStorm, add the specified Ide key in step 5 to PHP | Debug | Xdebug Proxy in the settings dialog box, and configure the Proxy Host and Proxy port.

Now, you can use the "listener" function. To access the application on the specified debugging server, click Start Listen PHP Debug connection in PHPStorm to Start listening to the debugging port;

Click xdebug Start Session in the browser bookmarks, enable the debug function, and then click xdebug this page, xdebug break on, xdebug break off, and so on to call PHP Storm and debug the program, it is very convenient to add or delete breakpoints and display the values of variables and expressions in the current state.

ForFramework/ProjectThe debugging method must be based on the above configurations, and then perform some configuration:

1. click the Run-Edit statements option in the menu.

2. in the pop-up dialog box, configure according to the figure:

3.: click "add", select PHP Web Application, enter the configuration name on the right, select the Server we just added, and enter the query string that may be required for debugging in the Start URL, select the default browser, and click Apply and OK to confirm the configuration.

4. then, there is another step:

Set breakpoints in the program;
In the toolbar, select the application to be debugged;
Click Start Listen PHP Debug Connections, that is, the red phone button, to make it green, that is, to Start listening to the PHP Debug connection;
So we can finally start.
Click the Debug button in, or select Run-Debug from the menu to start the Debug journey...

Other instructions

Based on the breakpoint configuration, or when the Debug URL is enabled, or after the POST, if PhpStorm listens to the Debug connection, it will immediately switch to the editor interface and jump to the breakpoint, the browser will wait for PhpStorm operations.

You can interrupt PhpStorm debugging at any time, or conveniently perform Step Into/Step Over/Run to cursor (this crash occurs ):

Those who are familiar with Java will be very kind to this interface.

Oh, I don't want to debug it, but PhpStorm always jumps out? Remember the call button. just click it and make it red.

Come here first, hmm. Do it yourself

Bytes. Configuration xdebug is not the first time, but...

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.