PHP Class documentor tool

by Andy Prevost

Sunday December 31 2023

Do a search on "PHP Documentation" and you'll get the top project documentation tools, likely the first one in the list will be PHP Documentor – definitely the leading package for creating documentation.

Problem is that every tool available now go well beyond just PHP projects and require a composer installation for dependencies.

Come on guys, most of us just need a basic documentation package to create simple documentation showing Project notes, Properties, and Methods (class functions).

I spent more time trying to find a simple package than I did writing my own. A single file solution that reads the class, parses every line looking for comments that start with '/**' and end with '*/'. There are two possibilities for these, either they are comments, or they are the class header.

Next is evaluating each line for the keyword " function" or "function(". If neither is found, it is a property. If it is found, it is a method.

Parsing each line was relatively simple. There were some exceptions, of course, but fairly simple to work around.

The only real "glitch" I ran into was the situation where parameters are defined over multiple lines. That happens particularly with arrays. I'm still working on a solution for that, in the meantime, I am using my new PHP Class documentor. The most recent can be seen at the PHPMailer Pro site.

I have now added this functionality to my free Tools For Developers site. Check it out.

◀ Previous Next ▶

Post a Comment