The Xdebug extension encourages you to troubleshoot your content by giving a great deal of profitable investigate data.
Now, if you run the phpinfo(); you can see the xdebug extension is enabled
By default Xdebug profile log name as cachegrind.out You can add extra parameters to make dynamic. For myself, I added %t-%s which formats are
if you enable the xdebug.profiler_enable. it will run every single script. It will run all the time. So instead of that enable the xdebug.profiler_enable_trigger, the benefit of using profiler_enable_trigger you can enable and disable profiling by just pass the special GET or POST parameter XDEBUG_PROFILE to a PHP script. It will turn on profiling just for the one PHP script that receives the parameter. You need not set a value for XDEBUG_PROFILE, it is sufficient to append the parameter to the URL: yourUrl.php?XDEBUG_PROFILE.
Installing Xdebug for XAMPP with PHP 7.x
Basic Requirements
- XAMPP for Windows: https://www.apachefriends.org/download.html
- The VC14 builds require to have the Visual C++ Redistributable for Visual Studio 2015 x86 or x64 installed
- The VC15 builds require to have the Visual C++ Redistributable for Visual Studio 2017 x64 or x86 installed
Setup
Download Xdebug for:
- PHP 7.0.x: https://xdebug.org/files/php_xdebug-2.5.5-7.0-vc14.dll
- PHP 7.1.x: https://xdebug.org/files/php_xdebug-2.5.5-7.1-vc14.dll
- PHP 7.2.x: https://xdebug.org/files/php_xdebug-2.6.0-7.2-vc15.dll
- Copy the file php_xdebug-2.6.0-7.2-vc15.dll to C:\xampp\php\ext
- Open the file C:\xampp\php\php.ini with Notepad++
- Disable output buffering: output_buffering = Off
- Scroll down to the [XDebug] section (or create it) and copy this lines
[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug-2.6.0-7.2-vc15.dll"
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "c:\xampp\tmp"
;36000 = 10h
xdebug.remote_cookie_expire_time = 36000
9. Restart the Apache (Stop/Start)
Now, if you run the phpinfo(); you can see the xdebug extension is enabled
phpinfo |
Here %s is used for modifying only xdebug.profiler_output_name and not for xdebug.trace_output_name.
And If you want to get the current profiling log file. you can call the function
xdebug_get_profiler_filename(), which returns the file name as a string
if you enable the xdebug.profiler_enable. it will run every single script. It will run all the time. So instead of that enable the xdebug.profiler_enable_trigger, the benefit of using profiler_enable_trigger you can enable and disable profiling by just pass the special GET or POST parameter XDEBUG_PROFILE to a PHP script. It will turn on profiling just for the one PHP script that receives the parameter. You need not set a value for XDEBUG_PROFILE, it is sufficient to append the parameter to the URL: yourUrl.php?XDEBUG_PROFILE.
Comments
Post a Comment
Thank you :)