

- #PHPSTORM TUTORIAL HOW TO#
- #PHPSTORM TUTORIAL INSTALL#
- #PHPSTORM TUTORIAL GENERATOR#
- #PHPSTORM TUTORIAL UPDATE#
- #PHPSTORM TUTORIAL CODE#
PhpStorm is now ready for an initial Xdebug session.
#PHPSTORM TUTORIAL UPDATE#
The settings should default to the following image, but if not make sure to update them: Click on PHP and then Debug on the left side. For the following steps, you should already be on a page in your application to proceed.

Xdebug debugging involves setting a breakpoint where you wish to pause script execution and then reloading the page in your browser. I’ve setup a sample domain, v to try this out.
#PHPSTORM TUTORIAL CODE#
There’s nothing special about it, and you don’t need to change anything in the code to make it work.
#PHPSTORM TUTORIAL INSTALL#
I have set up a fresh vanilla install of WordPress to test out Xdebug. Extremely easy, and no need to mess with the URL to pass in Xdebug flags! Your Code Whenever you want to initiate a debugging session simply click the “Start debugger” bookmarklet, and “Stop debugger” to end the session. I like to save mine inside a folder for easy access: You should drag these links into your browser’s bookmark bar. This is the key Xdebug/your IDE will be listening for.Ĭlicking the “Generate” button will create 7 links below the form. On the right side you’ll see the Xdebug IDE key field. These bookmarklets will work for any IDE, not just PhpStorm.

#PHPSTORM TUTORIAL GENERATOR#
It also provides bookmarklets for profiling and tracing features, which I will not be covering in this tutorial.įirst, go to PhpStorm’s Zend Debugger & Xdebug bookmarklets generator for PhpStorm. This bookmarklet allows you to simply click on a bookmark in your browser to instantiate an Xdebug session and just as quickly end it. Jetbrains, the creators of PhpStorm, have been nice enough to create an easy to use Xdebug/Zend Debugger bookmarklet. Search for xdebug and you should find it. If you’re using PHP 5.3, zend_extension should be /usr/local/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so xdebug.remote_enable = 1 xdebug.remote_connect_back = 1 xdebug.remote_port = 9000 xdebug.show_local_vars = 0 xdebug.var_display_max_data = 10000 xdebug.var_display_max_depth = 20 xdebug.show_exception_trace = 0 We’ll clone Xdebug from Github and compile it: If you’ve followed my Setting Up a Debian VM, Step by Step tutorial then you should already have Xdebug installed and enabled. The steps to get Xdebug working in your favorite IDE/text editor will differ, but the basic steps should remain the same and you should refer to its documentation. It is not free (except for educational institutions or open source projects) at $99, but in my opinion this is a must-have tool that just works and is worth every penny.Įdit: It appears ActiveState Komodo IDE supports Xdebug, but the price tag of $295 may be too much to pay for many non-professional developers. PhpStorm is a full-fledged IDE that is developed by the same team that has created IntelliJ IDEA. My favorite IDE is JetBrains’ PhpStorm which provides native support for Xdebug and I will write this tutorial with it in mind. Some text editors have plugins for Xdebug support, like Notepad++, Sublime Text 2 and even Vim. I will keep an eye on this IDE’s status and update this article as soon as I see that it works. Netbeans has an issue ( 1, 2, 3) with Xdebug where it throws a socket exception while debugging, rendering it kind of useless for any real debugging sessions. PHPed has a proprietary “PHP Debugger” extension. For example, Zend Studio does not officially support Xdebug, and in my tests it simply does not work – you need to use their own Zend Debugger.

Most modern IDEs support debugging of some sort, although depending on the IDE you may be required to use a different extension. It also allows you to change the values of one or more variables on the fly, affecting the execution of your application. Xdebug completely replaces the need to litter your code with echo, print_r() or var_dump() calls, and displays information on all variables, not just the one you passed. With it you can set a breakpoint and pause the execution of a script to see the state of your application at that exact point, including what variables/objects have been instantiated and what their values are. It provides debugging and profiling capabilities, although I’ll be mostly focusing on the debugging aspects in this tutorial. Xdebug is a PHP extension that was written and is maintained by Derick Rethans.
#PHPSTORM TUTORIAL HOW TO#
In my Setting Up a Debian VM, Step by Step tutorial I showed you how to install and enable Xdebug on a VM but I didn’t really explain what Xdebug is, why you should use it, or how to actually begin working with it.
