cDocPHP 0.1

I’m writing PHP code on a regular basis, and I need to document my code.

Problem: I’m lazy, and 9 out of 10 times, the basic phpDoc comments for functions or variables/properties are semantically identical.

Solution: cDocPHP.

It’s a little script I hacked together. It’s neither neatly written nor particularly great nor commented (hehe), but what it does, it does quite okay. So what does it do? Simple: it’s a little form where you can input a package name, your name (i.e. the author’s name) and upload a PHP file. When you submit, the script will process the uploaded file: it’ll be scanned line by line, and as soon as it finds a variable declaration (“var $xyz”) or a class declaration (“class xyz”) or a function declaration (“function xyz()”), a pile of pre-written phpDoc comment tags is inserted. If a function is found, it’ll scan the contents of the function, and if there is a return value specified, a “@return …” tag is added to the comments as well. That’s about it.

It’s not a killer app, but it’s a timesaver. Plus you don’t have to remember whether there was a return value or not. If the script added a return comment, then there was. Sure, you still have to fill in the nitty gritty, but in the end, you’ll save time nonetheless.

I wrote it because I needed something like it, it was written in a 20 minutes timeframe, and it’s cool for what it does. And so, with a honest tip to hat to Simon, I’ll share my love with you. If you like it, use it, if not, don’t. It’s as easy as this. ;) If you know a tool that does it better, please tell me – as I’ve said, I need all the documentation/tagging help I can get…