Using the Zend Studio configuration Xdebug Tutorial

Source: Internet
Author: User
Tags configuration php naming convention php debug php debugger php debugging tools php script php source code zend

Original address: http://www.leapsoul.cn/?p=935

Speaking of PHP code debugging, for experienced phper, through the Echo, Print_r, Var_dump function, or PHP development tools Zend Studio, EditPlus can solve most of the problems, but for the introduction of PHP to learn the children's shoes have a certain degree of difficulty, And just through these PHP debugging means, it is difficult to accurately detect PHP performance problems, Xdebug is a very useful PHP debugging tool.

Xdebug, as a PHP debugging tool, provides rich debugging functions, and can also configure Xdebug installation as Zend Studio, EditPlus debug Third-party plug-ins for PHP, and by turning on automatic tracking (auto_trace) and analyzer functions, You can visually see the PHP source code performance data in order to optimize the PHP code. Share with you today the basics of PHP Debugging Tools Xdebug installation and configuration.

The Xdebug installation configuration in PHP involves modifications to the php.ini configuration file.

Xdebug Installation Tutorial

Download Xdebug

First we need to download xdebug, be sure to install the PHP version, choose the appropriate xdebug version, because I am in the Windows environment installed PHP (refer to Windows 7 installation configuration Php+apache+mysql Environment Tutorial), So choose to download the Windows version of Xdebug2.1.0 (5.3 VC6), download the Xdebug file for Php_ Xdebug-2.1.0-5.3-vc6.dll, this is because the Xdebug is installed as a PHP module in the form of being configured and used.

Xdebug Installation Tips: If you do not know the installed version of PHP, you can refer to the Phpinfo () function, and Xdebug also provides Phpinfo output information analysis tool to help you analyze how to install Xdebug, as long as the Phpinfo output information replication submitted can be Address: Xdebug phpinfo Information Analysis Address

Install Xdebug

Copy the downloaded Php_xdebug-2.1.0-5.3-vc6.dll to the ext directory in the PHP installation directory, where the C:\php\ext,ext directory is dedicated to storing PHP extension library DLL files.

Configure PHP.ini

The final step in installing the Xdebug is to configure the php.ini file, open the php.ini configuration file in the C:\php directory, and add at the end

1
2
[Xdebug]
zend_extension= "C:/php/ext/php_xdebug-2.1.0-5.3-vc6.dll"

Finally reboot the Apache server, through the Phpinfo () function, you can see

PHP Xdebug configuration information

XDEBUG configuration Hint: PHP5.3 Previous version configuration Xdebug use Zend_extension_ts, for PHP5.3 above version, use Zend_extension.

XDEBUG not LOADED as ZEND why extension information appears

The reason for the Xdebug not LOADED as ZEND extension is that when you install Xdebug, because we copy the Xdebug DLL file to the Php\ext directory, it is easy to load xdebug in the form of a PHP extension library, Added in the php.ini file

1
Extension=php_xdebug-2.1.0-5.3-vc6.dll

This is the wrong Xdebug installation method and must be loaded in Zend mode.

Now that the basic installation tutorial for PHP Xdebug is over, we need to make some basic configurations for xdebug.


Xdebug Configuration Tutorial

After the installation of Xdebug, we also need to do the basic configuration of Xdebug, the default xdebug PHP function automatic tracking (auto_trace) function, analyzer function is not turned on, as the need to debug PHP code, some xdebug configuration option is best to open.

Before that we needed to create a directory of Xdebug automatic tracking and parser output files, making sure that the directory was readable and writable, where I created Xdebug\trace and Xdebug\profiler directories under D:\PHPWeb\.

Finally, in the php.ini configuration file to complete the Xdebug configuration work, find

1
2
[Xdebug]
zend_extension= "C:/php/ext/php_xdebug-2.1.0-5.3-vc6.dll"

Add Xdebug configuration information after this

1
2
3
4
5
6
Xdebug.auto_trace=1
Xdebug.collect_params=1
Xdebug.collect_return=1
Xdebug.trace_output_dir= "D:/phpweb/xdebug/trace"
Xdebug.profiler_enable=1
Xdebug.profiler_output_dir= "D:/phpweb/xdebug/profiler"

Finally, save the php.ini and restart the Aapche server.

Xdebug Partial configuration options description

Xdebug.auto_trace = 1

Whether to allow Xdebug trace function calls, trace information stored as files, default value 0

Collect_params = 1

Whether to allow Xdebug trace function parameters, the default value is 0

Xdebug.collect_return = 1

Allow the Xdebug trace function to return a value with a default value of 0

xdebug.profiler_enable = 1

Open the Xdebug Performance Analyzer, stored as a file, which cannot be configured with the Ini_set () function, with a default value of 0

Xdebug.profiler_output_dir

Where the profiling file is stored, the default is/tmp

Xdebug.profiler_output_name

The naming convention for profiling files, the default value is cachegrind.out.%p

Xdebug.trace_output_dir

function call trace information output file directory, default is/tmp

Xdebug.trace_output_name

function call trace information output file naming rules, default to Trace.%c


tutorial on configuring Xdebug for Zend Studio

Open the PHP installation directory (how to install the configuration PHP.) ) under the php.ini configuration file, my C:\PHP directory, find Xdebug configuration information, add the following xdebug configuration information on this basis

1
2
3
4
Xdebug.remote_enable=true//xdebug allows remote IDE connections
xdebug.remote_host=127.0.0.1//Allow connected Zend Studio IP address
xdebug.remote_port=9000//Reverse connect the ports used by Zend Studio
XDEBUG.REMOTE_HANDLER=DBGP//Application Layer Communication protocol for Zend Studio remote debugging

Important NOTE: Here is easy to overlook a problem is the configuration of xdebug.remote_host information, if you are using a LAN or wireless router, the Xdebug.remote_host configuration for 127.0.0.1 is useless, will lead to the inability to use Zend The Single step debug button for studio Debugging Php,zend Studio is also invalid. The xdebug.remote_host must be configured as the actual address of the Zend Studio installation machine, the IP address can be viewed through ipconfig, and since I am using a wireless router, I will Xdebug.remote_ The host configuration is 192.168.1.100.

Finally reboot the Apache server.

Ok, now we can use Xdebug to debug in Zend Studio.

Because the Zend Studio default support for debugging PHP is Zend Debugger, you first need to configure the Zend Studio PHP debug option to Xdebug to use Xdebug.

Zend Studio uses Xdebug to debug PHP step one

Open Zend Studio7, select Menu Project->properties, and then select the left PHP debug option in the pop-up interface, as shown in

Configuring the Use of Xdebug debugging PHP tutorial in Zend Studio

Check the Enable project specific settings option and select the Xdebug option in the PHP debugger option, and then click OK.

Note: When using Zend Studio to debug PHP, sometimes there is a problem, that is, Zend Studio debugging PHP files without using Xdebug for debugging, you can click on the top left of the Project window to select specific project or project files, Right-click to select the Properties option to configure the interface as shown above.

Use Xdebug to debug PHP source in Zend Studio

Using Zend Studio to debug PHP, mainly through the debug as menu, there are three options for PHP Script, PHP web page, PHP unit Test, where you can select PHP Web page and use Zend for the same PHP file. Studio debugging PHP did not choose to use xdebug, you need to clear the old debug files, you can use the Debug Configurations menu to clear the above three kinds of Zend Studio debugging methods in the file, this is the choice of PHP Web Page, So just clear the files in this key.

Debug configurations can be entered in three ways: 1, right-click PHP files that need to be debugged, select Debug as or open debug PHP file, 2, select Debug as Enter under the Run menu on menu bar, 3, Click the down arrow next to the small spider icon under the menu bar Run menu to select Debug Configurations.

After debug configurations is configured, open the PHP file that requires Zend Studio debugging to select the PHP Web page option in debug as, check the launch URL and click OK to debug, xdebug in Zend Graphics for debugging PHP files in Studio

Using Xdebug to debug PHP tutorials in Zend-studio

As shown in the diagram you can debug the PHP file through a single step debugging (F5), as long as the Xdebug configuration is correct, in the Debugging Code window will appear the selected light green background code, or the Single Step debugging (F5) function is invalid.


Note: There are sometimes 9000 port conflict problems ...



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.