0% found this document useful (0 votes)
71 views3 pages

Activate Use Xdebug

Xdebug is an open source PHP debugger and profiler that is included with XAMPP. It allows displaying stack traces, code coverage analysis, and profiling PHP code. To activate Xdebug, edit the php.ini file to load the xdebug extension and restart Apache. Verify activation using phpinfo(). Xdebug overloads var_dump() for colored output. Script profiling is enabled by editing php.ini settings and will output cachegrind files for analysis.

Uploaded by

nyenius
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views3 pages

Activate Use Xdebug

Xdebug is an open source PHP debugger and profiler that is included with XAMPP. It allows displaying stack traces, code coverage analysis, and profiling PHP code. To activate Xdebug, edit the php.ini file to load the xdebug extension and restart Apache. Verify activation using phpinfo(). Xdebug overloads var_dump() for colored output. Script profiling is enabled by editing php.ini settings and will output cachegrind files for analysis.

Uploaded by

nyenius
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Activate and Use Xdebug

Xdebug is a powerful open source debugger and profiler for PHP. It is included with XAMPP and can be used
to display stack traces, analyze code coverage and profile your PHP code.

To activate Xdebug, follow these steps:

1. Edit the php.ini file in the etc/ subdirectory of your XAMPP installation directory (usually,
/Applications/XAMPP). Within this file, activate the Xdebug extension by adding the following line to it:

extension = xdebug.so

2. Restart the Apache server using the XAMPP control panel.

Xdebug should now be active. To verify this, browse to the URL http://localhost/xampp/phpinfo.php, which
displays the output of the phpinfo() command. Look through the script and verify that the Xdebug extension is
now active.

Xdebug overloads the default var_dump() function with its own version that includes (among other things) color
coding for different PHP types, so you can see it in action immediately by using the var_dump() function in a
PHP script. For example, create a simple PHP script in the htdocs/ subdirectory of your XAMPP installation
directory with the following content:

<?php
var_dump($_SERVER);

When you view your script through a browser, heres an example of what you might see:

One of Xdebugs most powerful features is its ability to profile a PHP script and produce detailed statistics on

1
how long each function call or line of code takes to execute. This can be very useful for performance analysis
of complex scripts. To turn on script profiling, follow these steps:

1. Edit the php.ini file in the etc/ subdirectory of your XAMPP installation directory. Within this file, add the
following section:

[XDebug]
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "/tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"

2. Restart the Apache server using the XAMPP control panel.

At this point, XDebug profiling is active. Every PHP script that you run will be profiled and the results will be
placed in the /tmp/ directory as a so-called cachegrind file. You can view this cachegrind file with a tool like
WebGrind or qcachegrind, which you must download and install separately.

TIP To find out more about Xdebugs powerful features, read the Xdebug documentation.

You might also like