You are viewing...

Installing XDebug Painlessly and Using it with PHPDesigner! (Windows Only)

Updated on May 27, 2011 at the 03th hour
Posted under:

DISCLAIMER: All views are considered my own and you should not draw any conclusions on associates.

Alright, fans! You are likely to be here not because you are looking for how to install XDebug because there are many other sites that show you how to, even XDebug’s site shows you how to. Heck, they even have a little phpinfo(); analyzer to tell you what dll you need and what to enter into the config. You know what? That’s exactly where I’m going to point you.

XDebug Installation

1. Go to XDebug’s main site.

2. Go to Download/SVN in the horizontal menu. Once you there click “Custom Installation Instructions” (provided link for lazy people)

3. Go to your webserver directory and create a .php file, add phpinfo(); to it, execute the script by going to the script in the browser.

4. Right click the page and go to view source or its equivalent. Copy all of it and paste it into box on the XDebug’s custom installation page. Analyze it.

5. It should give you the dll and the instructions you’d want. [Make sure if you are using PHP 5.3 that you use zend_extension and not zend_extension_ts like on other sites.]

That’s it for installation!

For those who want to see my php.ini settings for XDebug:

zend_extension="C:{DIRECTORY OF PHP}extphp_xdebug-2.1.1-5.3-vc9.dll"
;xdebug.remote_connect_back = 1
xdebug.remote_mode=jit
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir="C:{DIRECTORY OF PHP}logsxdebug"
xdebug.profiler_append=On

You are probably wonder WTF is all of this. Don’t worry you’ll understand this once you go to the XDebug Documentation. If you look at remote_mode, I set it to jit so that anytime an error comes up when I execute a script in the browser XDebug would initiate a debug session in PHPDesigner!

__________________________________________________________________

PHPDesigner Instructions (So easy)

1. Go to PHPDesigner’s main site.

2. Buy, download, and install PHPDesigner! It’s such a good IDE for Windows or you can use Eclipse PDT, but that’s not the focus here.

3. Start up PHPDesigner and go to the preferences. (You can probably get away without touching the preferences)

4. Go straight to Debugger and set the PHP and Connfig ini to where your PHP installation is. Make sure you are using php-cgi.exe. (I recommend doing the same for Syntax Check [I use php.exe] and Run suboptions under Debugger)

5. In the Debugger pref, make sure listen port is 9000 or whatever you set it to in the php.ini. Also make sure that the XDebug server is started every time PHPDesigner starts.

6. Save the preferences.

Done with PHPDesigner!

Alright, time to actually use it!

Well, open up any script and press debug under the Debug menu. You’ll see that it asks to break on the first line, press yes! Voila! That’s great, its working, now we can press F7 to go to the next line and then use F8 to start stepping over or you can place a breakpoint somewhere and have the debugger stop there.. whatever satisfies your need.

You’ll soon find out that you don’t have access to HTTP_HOST, REMOTE_ADDR, or any useful server variables… Well, that’s to be expected since you are using PHPDesigner’s internal debug server at this point. We’ll have to execute a script in the browser and have XDebug start a session that PHPDesigner can pick up.

Remember the remote_mode I mentioned up there? We can change it to req, which basically mean start a session on every request. Restart apache and execute a script. You’ll find that the browser is waiting for something to happen. Go back to PHPDesigner and you’ll see that it has picked it up and you can debug your scripts using it! With the useful things you want and everything. Once you’ve confirmed it working, you can change remote_mode back to jit.

Note: You can manually start a debug session by adding ?XDEBUG_SESSION_START={session} to your url. ({session} should be replaced with whatever name or just remove the braces) PHPDesigner will pick up the XDebug session.

Now that everything is working, go crazy debugging your scripts!

P.S. I’m sorry linux fans, as much as I love Fedora as a linux distro, it should be dead simple to install XDebug. Simple as a ‘yum install php-pecl-xdebug’. Oops!

You just read "Installing XDebug Painlessly and Using it with PHPDesigner! (Windows Only)". Please share if you liked it!
You can read more recent posts here.