📜 ⬆️ ⬇️

XDebug - if you are tired of echo (), var_dump () and print_r () when debugging. Part 2.

First part

Official website for the project - www.xdebug.org
Settings, in parentheses indicate the version (for example, Xdebug 2) - www.xdebug.org/docs-settings.php
Documentation - www.xdebug.org/docs.php

Installing XDebug2 under Windows
')
1. Download the extension for the PHP version you need:
- PHP 4.4.1+
- PHP 5.1.2+
- PHP 5.2.1+

2. We rule php.ini:
; path to the downloaded extension (specify your own). if it doesn't work, replace zend_extension_ts with extension
zend_extension_ts = "C: \ program files \ php \ extensions \ php_xdebug.dll"
; on / off profiling (1/0)
xdebug.profiler_enable = 1
; directory for profiling results (default)
xdebug.profiler_output_dir = "c: \ program files \ php \ tmp_xdebug"

Script execution data is written to a cachegrind file (text file). These files are read by the Windows WinCacheGrind utility.

Installing XDebug2 for Linux

1. Download the source code
2. We rule php.ini:
; on / off profiling (1/0)
xdebug.profiler_enable = 1
; directory for profiling results (default)
xdebug.profiler_output_dir = "/ data / home / user / projects / tmp_xdebug"
3. Next smoke manual :)

Configure XDebug

If you have one project on which you are working, then XDebug directives can be written in the php.ini file. They will act on all projects on your web server.

If you need to configure XDebug individually for each project, then use php_value in the .htaccess file (Apache)

Setup Example:
# Change the path to the log on your own (+ create a directory for the log)
<IfModule mod_php4.c>
# path to XDebug log
php_value xdebug.profiler_output_dir / data / home / user / your_project / tmp_xdebug

#php_value xdebug.trace_output_dir / data / home / user / your_project / tmp_xdebug

# plugin auxiliary file for WinCacheGrind Windows utility (shows profile-log)
# When debugging in the address bar of the browser, enter the GET parameter? XDEBUG_PROFILE (http: // yourhost /? XDEBUG_PROFILE). Open WinCacheGrind result
php_value php_value auto_prepend_file /data/home/user/your_project/Debug.class.php

# autoscan off
php_flag xdebug.auto_trace 0

# important option. When 1, the log will be saved, if 0, it is issued with the GET parameter XDEBUG_PROFILE (http: // yourhost /? XDEBUG_PROFILE)
php_flag xdebug.profiler_enable 0

php_flag xdebug.profiler_enable_trigger 1

# collect parameters, return values, variables (0 - off, 1 - on)
#php_flag xdebug.collect_params 0
#php_flag xdebug.collect_return 0
#php_flag xdebug.collect_vars 0

# disables error handling by the profiler, 1 enables
#php_flag xdebug.default_enable 1
# show log memory usage between function calls
php_flag xdebug.show_mem_delta 1

# 1 - clear log output
php_flag xdebug.trace_format 0

#timestamp - second output file name format
#php_value xdebug.trace_output_name crc32

php_value xdebug.profiler_output_name pid
</ IfModule>


Full list of settings .



An auxiliary file for getting the log profile via a GET parameter and viewing WinCacheGrind ( download ), the original code was taken a year ago from the dklab forum

Source: https://habr.com/ru/post/7424/


All Articles