Debugging on local Apache with PhpED

I’ve been working with PhpED for quite some time, but now that I’m using the Zend Framework I reached the point, where the integrated server isn’t good enough anymore. The main concern was mod_rewrite. I needed a way to debug on my local Apache installation (XAMPP to be specific).

I fought my way through multiple blogs and forums to get it all up and running. Here are my condensed facts for Apache and PhpED on Windows XP. This might be a little bit too detailed. If you think “Man, I really want to debug on my local Apache” you’ll probably know how to add extensions to your PHP environment, but I’ll tell you anyway:

Getting the debugger extension

PhpED comes with a variety of debugger extensions. They can be found in a subdirectory of your PhpED installation. For me that’s

c:\Program Files\phped\debugger\server\Win32\x86

Here we have extensions for different versions of PHP. I chose

php_dbg.dll-5.2.x

Where to put the extension now?

Make yourself a quick and dirty phpinfo.php file and put it in your project root.

<?php
   phpinfo();
?>

Open your project in your browser (Time for me to recommend a vhost once more). It’s really important that you don’t start that file from PhpED since it’ll use it’s own PHP environment and that’s exactly what we want to avoid. Now look for the extension_dir entry in the Configuration > PHP Core section. It should say something like

C:\xampp\php\ext\

Now get your php_dbg.dll-5.2.x and put it into your extension_dir. Trim the version information. What’s left will be

php_dbg.dll

Telling PHP what to do

Go back to your browser and go to the top of your phpinfo page. Look for the php.ini in use (Loaded Configuration File) and open it in the editor of your choice (I guess it’ll be PhpED, right?). Scroll down (or search for) the section named Dynamic Extensions. Add a new line:

extension=php_dbg.dll

Next we’ll configure the debugger. At the end of your php.ini add the following:

[debugger]
debugger.enabled=on
debugger.profiler_enabled=on
debugger.hosts_allow=ALL
;debugger.hosts_deny=ALL
debugger.ports=7869, 10000/16

This might be a little bit risky. I don’t have to share my development environment with other people and my system isn’t reachable from the outside world. You might want to have a closer look at debugger.hosts_allow. If you want to play it safe, uncomment the debugger.hosts_deny entry to block everyone, then add your allowed hosts to debugger.hosts_allow.

Restart your Apache. Go back to your browser and hit refresh. Next to the Zend Engine 2 logo you should see something like “with DBG v3.1.11, (C) 2000,2007, by Dmitri Dmitrienko”. If you see it: You’re almost done. If you don’t see it: You probably changed the wrong php.ini.

Setting up your project in PhpED

Open PhpED and go to your project properties. In the Mapping section change Run mode to HTTP Mode (3rd party WEB server) and let the Root URL point to your project server.

Basically that’s it!

Troubleshooting

I had some problems when debugging the first times. Apache crashed with an Windows exception once the page started loading. Try the following: Go back to your php.ini and search for [Zend]. If you don’t know, if you need these settings, then you probably won’t. Try to go without them by commenting them.

[Zend]
;zend_extension_ts = "C:\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll"
;zend_extension_manager.optimizer_ts = "C:\xampp\php\zendOptimizer\lib\Optimizer"
;zend_optimizer.enable_loader = 0
;zend_optimizer.optimization_level=15
;zend_optimizer.license_path =
; Local Variables:
; tab-width: 4
; End:

Restart your Apache after you’re done!

Sources

NuSphere support forum
Darren Beals blog
PHPEclipse forum

5 Comments

  1. Posted May 10, 2008 at 4:48 | Permalink

    I found your site on faves.com bookmarking site.. I like it ..gave it a fave for you..ill be checking back later

  2. Posted September 7, 2008 at 14:46 | Permalink

    Thanks! That helped me a lot!

  3. Posted January 30, 2009 at 6:22 | Permalink

    Hi,

    It is really useful information. It helped me to setup.

    Thanks

  4. ssl12
    Posted February 3, 2009 at 2:03 | Permalink

    if you have crashes in Apache and you need zendoptimizer for loading files encoded by zend’s guard, check and upgrade if needed to debugger v3.6.8 or higher or at least make it loaded before zendoptimizer in php.ini.
    The real problem is in Zend Extension Manager which has one bug that may expose itself only when non-Zend’s zend_extension is loaded. May be that was made intentionally. Who knows…
    Workaround for this problem is advertized in dbg version 3.6.8.

  5. Aniruddha S
    Posted June 24, 2010 at 7:31 | Permalink

    Hi Datensarg,

    I have tried debugging in PhpEd with local SRV web server. Its really cool.
    But when I started debugging one of my CodeIgniter applications, I got stuck with .htaccess and mod_rewrite issues.
    Then I thought its time to switch to apache and found this blog of yours.
    Its really nice and easy. Very Useful. Done in 2 mins without much fuss.

    Thanks. Keep up the good work.

    Regards,
    Aniruddha S.

Post a Comment

Your email is never shared. Required fields are marked *

*
*