[pmwiki-devel] Debugging recipes

Petko Yotov 5ko at 5ko.fr
Sun May 10 10:46:36 CDT 2009


On Sunday 10 May 2009 01:48:08 Simon wrote:
> but I'd appreciate some suggestions of advice on the tools you use to debug
> and develop PmWiki recipes and core.
>
> There are a couple of recipes I'd like to fix.
> What sort of environment do you develop in,
> IDE, debugger (I'd like to step through the code as it executes),
> and any tips on debugging it given it is a server/web application.

Hi. I am working on Kubuntu GNU/Linux and I use mostly KDE applications:
* Krusader - file manager
* Kate - text editor (great features: all encodings, syntax highlighting,
  sessions)

One great thing in KDE is that you can "mount" virtual filesystems, so you can 
browse/compare/edit files on remote servers via FTP or SSH protocols, like if 
they were on your local hard disk. So I mostly edit files that are live on my 
wikis. This way I also am required to fix or revert anything that is broken, 
immediately.

For PHP step by step debugging, I have used some functions for many years 
(very basic, but work for me). These are in my farmconfig.php:

  /// Debug functions
  function xmp($stuff, $die=0){
    echo "<xmp>";
    if(is_array($stuff)) print_r($stuff);
    else echo $stuff;
    echo "</xmp>";
    if($die) die();
  }
  function xmps($x, $d=0){ # "safer" xmps
    if(! $_SERVER['REMOTE_ADDR']=='my.own.ip.address') return false;
    xmp($x, $d);
  }

When I want to check a variable in the middle of some function, I write one of 
those:
  xmp($var);     # prints the variable on top of the page
  xmp($var, 1);  # ... and exits
  xmps($var, 1); # only print and exit for me (my ip address)


A pmwiki-specific function that doesn't mess with http headers is "sms" from:
  http://www.pmwiki.org/wiki/Cookbook/DebuggingForCookbookAuthors


I also have bookmarks in Firefox that are shortcuts to important searches.

  http://php.net/search.php?lang=en&show=quickref&pattern=%s
  with keyword 'php'

When I type in the address bar of the browser, for example "php array merge" 
it searches the php.net reference for the function (array_merge) and opens 
the page if the function exists, or shows suggestions.

I have similar shortcut-searches for Wikipedia, Google and PmWiki.org.

Firefox has also a great extension for inspecting webpages : Web Developer.


I mostly don't do programming on Windows except when I need to test skins/css 
on various browsers. And it's a pain. KDE4 can be installed on Windows, and 
Kate works, but I wasn't able (yet) to directly edit remote files. 

Among other free software text editors for Windows, I have used SciTE and 
Notepad++. The latter, I found lately, has a remote-sync plugin that should 
make it easier to edit remote files. (I haven't used it much). 

I don't use non-free software unless there is absolutely no way around, so I 
haven't tested text editors that others suggested (ultraedit, editplus, ...).

Thanks,
Petko



More information about the pmwiki-devel mailing list