Home >Backend Development >PHP Tutorial >xdebug installation and configuration instructions in PHPstorm_PHP tutorial

xdebug installation and configuration instructions in PHPstorm_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:08:31919browse

This article will introduce to you the installation and configuration instructions of xdebug in PHPstorm. This is not the first time I have configured PHPstorm. Let me share my experience with you.

This is not the first time to configure xdebug, but this is the first time to configure xdebug with phpstorm (I think my error correction ability is quite strong, plus my familiarity with the framework, I can quickly fix the problem file if I know its location) code, there is no need to use xdebug+IDE to debug and find problems). I haven’t had time to mess around with IDE-level things since I started my new job in April. Today I finally have some free time to do whatever I want~

Since installing and configuring xdebug is a commonplace topic, I will not describe the method and process of installing xdebug here. I will only explain the configuration requirements of the xdebug part for the php.ini 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

" Regarding how to configure xdebug.so, there are instructions 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-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 the ISAPI module). Note: In case you compiled PHP yourself and used –enable- debug you would 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 calls '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 should appear twice there (once under 'PHP Modules' and once under 'Zend Modules').

"Whether you use zend_extension_ts, zend_extension or Shenma Shenma depends on the PHP version. Please read the instructions above 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 am using phpstorm5.0.4, even if it is a lower version, it does not matter. The configuration method described in this tutorial is common in versions 4.0~5.+.

1.File>Settings, PHP | Server: Click the + symbol, enter the name you specified for the server in the Name column, and enter the address of the debugging server in the Host column, without starting with "http://". Enter the server product in the Port column (usually the default value is 80), and select Xebug in the Debugger column.

Select Xebug in the Debugger column.

xdebug installation and configuration instructions in PHPstorm_PHP tutorial

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

xdebug installation and configuration instructions in PHPstorm_PHP tutorial

3. Click Use debugger bookmarklets to initiate debugging from your favorite browser to configure debugger bookmarks in the system's default browser.

4. The default browser is opened, enter http://www.jetbrains.com/phpstorm/marklets/, and modify the Ide key under the Xebug column. The default is PHPSTORM.

5. Click the Generate button in the Xdebug column and add the Xdebug group in the browser's bookmarks, which contains various items of Xdebugger.

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

At this point, you can use the "Listening" function. As long as you access the application on the designated debugging server, first click the Start Listen PHP Debug connection button in PHPStorm to start monitoring the debugging port;

red button

Click xdebug Start Session in the browser bookmark to turn on the debug function, then click xdebug this page, xdebug break on, xdebug break off, etc. to call PHP Storm to debug the program, add and delete breakpoints, and display the current status It is very convenient to download the values ​​of variables and expressions.

In addition, the debugging method for the framework/project requires some additional configurations based on the above configuration:

1. Click the Run – Edit Configurations option in the menu.

2. In the pop-up dialog box, configure according to the picture:

xdebug installation and configuration instructions in PHPstorm_PHP tutorial

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

4. Then, there is one more step:

xdebug installation and configuration instructions in PHPstorm_PHP tutorial

Set breakpoints in the program;
In the toolbar, select the application you want to debug;
Click the Start Listen PHP Debug Connections button, which is the red phone button, and let it turn green to start listening for PHP Debug connections;
So, finally we can start.
Click the Debug button in the picture above, or select Run – Debug from the menu, and you will start the Debug journey...

Other instructions

According to the breakpoint configuration, or during the process of opening the Debug URL, or after POST, if PhpStorm listens to the Debug connection, it will immediately switch to the editor interface and jump to the set breakpoint. The client will wait for PhpStorm's operation.

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

xdebug installation and configuration instructions in PHPstorm_PHP tutorial

Children who are familiar with Java will feel familiar with this interface, hahaha.

Oops, I don’t want to debug, but PhpStorm keeps popping up? Remember the phone button just now, click it again and make it red.

Here we go first, huh. Just tinker with it yourself

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629824.htmlTechArticleThis article will introduce to you the xdebug installation and configuration instructions in PHPstorm. This is not the first time I have configured PHPstorm. Here are the instructions Share your experience with you. This is not the first time to configure xdebug, but...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn