diff --git a/_posts/03-06-01-XDebug.md b/_posts/03-06-01-XDebug.md new file mode 100644 index 0000000..ce78520 --- /dev/null +++ b/_posts/03-06-01-XDebug.md @@ -0,0 +1,35 @@ +--- +isChild: true +--- + +## XDebug {#xdebug_title} + +One of the most useful tools in software development is a proper debugger. It allows you to trace the execution of your +code and monitor the contents of the stack. XDebug, PHP's debugger, can be utilized by various IDEs to provide +Breakpoints and stack inspection. It can also allow tools like PHPUnit and KCacheGrind to perform code coverage analysis +and code profiling. + +If you find yourself in a bind, willing to resort to var_dump/print_r, and you still can't find the solution - maybe you +need to use the debugger. + +[Installing XDebug][xdebug-install] can be tricky, but one of its most important features is "Remote Debugging" - if you +develop code locally and then test it inside a VM or on another server, Remote Debugging is the feature that you will +want to enable right away. + +Traditionally, you will modify your Apache VHost or .htaccess file with these values: + + php_value xdebug.remote_host=192.168.?.? + php_value xdebug.remote_port=9000 + +The "remote host" and "remote port" will correspond to your local computer and the port that you configure your IDE to +listen on. Then it's just a matter of putting your IDE into "listen for connections" mode, and loading the URL: + + http://your-website.example.com/index.php?XDEBUG_SESSION_START=1 + +Your IDE will now intercept the current state as the script executes, allowing you to set breakpoints and probe the +values in memory. + + * [Learn more about XDebug][xdebug-docs] + +[xdebug-docs]: http://xdebug.org/docs/ +[xdebug-install]: http://xdebug.org/docs/install \ No newline at end of file