Showing posts with label xdebug. Show all posts
Showing posts with label xdebug. Show all posts

2014-08-06

Tips & Techniques for debugging PHP (part 4)

Debuggers are software that have been specifically created for this task: debugging. When you use a debugger, you get a "Swiss Army Knife" array of tools to help you in the task of tracking down the location of, finding and removing the causes of bugs.

For PHP, the debugger is XDebug. It has integrations for all populars IDEs such as Eclipse, Netbeans, PHPStorm, etc.

http://xdebug.org

For easy installation, I would suggest you check out the XDebug Wizard

http://xdebug.org/wizard.php

What it needs is the output from phpinfo()
Just create a simple checkinfo.php file with just
<?php
phpinfo();

Paste it into the form on the XDebug Wizard page. Customized installation instructions would be provided. For the binary library file for Xdebug, I have found that most installations of PHP already have the XDebug binary included, but it just needs you to uncomment the php.ini file to activate it. For example, I have included the XDebug section for my xampp php.ini (noticed that I uncommented some lines).
The additional line is the one xdebug.remote_port=9000 which is the additional line I added because I am using Netbeans and the default configuration in Netbeans uses 9000 as the debug port. http://xdebug.org/docs/remote

[XDebug]
zend_extension = "D:\xampp\php\ext\php_xdebug.dll"
;xdebug.profiler_append = 0
xdebug.profiler_enable = 1
;xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "D:\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_port=9000
xdebug.trace_output_dir = "D:\xampp\tmp"


For more details about using XDebug and Netbeans configuration, please refer to the Netbeans documentation help pages. 
http://wiki.netbeans.org/HowToConfigureXDebug
https://netbeans.org/kb/docs/php/configure-php-environment-windows.html#installAndEnableXDebug


For more info on using XDebug refer to
http://devzone.zend.com/1120/introducing-xdebug/
I will be talking more about tracing and neat other things you can do with XDebug later on in another part of this PHP debugging series of posts.
 

Github CoPilot Alternatives (VSCode extensions)

https://www.tabnine.com/blog/github-copilot-alternatives/