This blog is a dumping-ground for research, thoughts and developments. dgtlmoon@gmail.com
skype: dgtlmoon
So it's been a good few years since I've felt the soft caress of a good breakpoint conditional debugger environment, last time I had really got my hands dirty was either in VisualStudio 6 or Watcom 10. I'm not claiming PHP is a great language, infact it's got a few shortfalls but one thing it is good for is getting the job done, up until now ive always just used a generous supply of print_r()'s and watchdog() entries, I really know better than this but without a good IDE, often it really is easier just to pepper a few of these babies around and see what happens, generally theres not really a lot going on that you cant figure out in a few well placed debugging entries.
Anyway, heres how I got Zend Studio & Zend Debugger working with Drupal, In this setup i chose to keep my existing PHP 5.2 setup from current Debian (Lenny). There are 3 main parts, install and configure the zend debugger to php, Enable Drupal to be debug-environment aware, and connect the Zend Debugger to Drupal, sounds tricky but its pretty straight forwards.
First, you need to get the Zend Studio and Zend Debugger installation files.
I just created a dir off my ~ called "zend" and ran the two binaries there, they should be self-extractors.
You should have the following files available
$HOME/zend/ZendDebugger-5.2.6-linux-glibc21-i386/5_2_x_comp/ZendDebugger.so
zend_extension=/home/dgtlmoon/zend/ZendDebugger-5.2.6-linux-glibc21-i386/./5_2_x_comp/ZendDebugger.so zend_debugger.allow_hosts=127.0.0.1 zend_debugger.expose_remotely=always
now fully restart apache so it makes the php binaries reload, if no errors maybe just drop a phpinfo(); into a script so you can see if it has loaded the extention correctly, you should have something that looks like
Zend Debugger Expose Zend Debugger always Passive Mode Timeout 20 seconds Connector PID 15557 Directive Local Value Master Value zend_debugger.allow_hosts 127.0.0.1 127.0.0.1 zend_debugger.allow_tunnel no value no value zend_debugger.connect_password no value no value zend_debugger.connector_port 10013 10013 zend_debugger.deny_hosts no value no value zend_debugger.httpd_uid -1 -1 zend_debugger.max_msg_size 2097152 2097152 zend_debugger.tunnel_max_port 65535 65535 zend_debugger.tunnel_min_port 1024 1024
So this means PHP is running and ready to take debugger connections on port 10013 on localhost (127.0.0.1)
Ok next step is to make any request to drupal bootstrap a special piece of code thats required so you can run with breakpoints in drupal - when you installed that ZendDebugger there would have been a script called "dummy.php" this script has some commands that activate the zendebugger.so, i found the best place to drop this in - although MAYBE it would work as a drupal module on its own, is to put the following into the root of drupal installation called "dummy.php", this is exactle the same as the stock dummy.php except we've deleted out the 'exit()' so it always carries with drupal.
dummy.php
<?php
@ini_set('zend_monitor.enable', 0);
if(@function_exists('output_cache_disable')) {
@output_cache_disable();
}
if(isset($_GET['debugger_connect']) && $_GET['debugger_connect'] == 1) {
if(function_exists('debugger_connect')) {
debugger_connect();
} else {
echo "No connector is installed.";
}
}
?>
Now after the first line of the index.php in drupal (inside the <?php , place the following
include_once 'dummy.php';Now access your site, nothing should change, just make sure things still work.
Ok step three!
By default zend studio will be looking for this "dummy.php" but it doesnt exist! we've rolled it into our drupal installation.
So what we do is set the "dummy file" field to "index.php" and just set the "Debug Server URL" to the path of my devel site, this case http://dgtlmoon.localhost/, no other settings are changed, it should default to connect in "Debug Mode" as "Server" so it does the server<->client business
Now to test it, let's place a breakpoint when the blog.module generates the form via it's hook_form implementation, what we expect is the debugger to kick in when this happens, so goto blog.module in the ZendStudio and click on the line number after where there is
function blog_form(&$node) {
the background should turn RED which indicates a breakpoint is set.
Additionally theres a firefox plugin which seemed to be automatically installed that can trigger this to work with zend.
Now at this point your browser should hang and there should be some action in your ZendDebugger - hit F10 to step over and you can see what happens, browse variables or F5 to continue on! from here you should read the tutorials on setting watches, conditional breakpoints, browsing/changing variables etc.
have fun :)
| Attachment | Size |
|---|---|
| php.ini | 41.49 KB |
| dummy.php.txt | 324 bytes |
| index.php.txt | 901 bytes |
| zend-browser.jpg | 4.2 KB |
In computing, a device
In computing, a device driver or software driver is a computer program allowing higher-level computer programs to interact with a hardware device.
A driver typically communicates with the device through the computer bus or communications subsystem to which the hardware connects. Free driver downloads, when a calling program invokes a routine in the driver, the driver issues commands to the device. Once the device sends data back to the driver, the driver may invoke routines in the original calling program. Drivers are hardware-dependent and operating-system-specific. They usually provide the interrupt handling required for any necessary asynchronous time-dependent hardware interface.
Displays, Bios, Sound, Printers drivers, Notebook