Generate php documentation from source code

UsageEasy to install, and to use!

Getting started using the PHAR

Start by downloading our latest PHAR file and giving it a nice and cozy place on your hard drive.

$ wget https://phpdoc.org/phpDocumentor.phar

After you downloaded the PHAR file, don't forget to power it up by making it executable.

$ chmod +x phpDocumentor.phar
Also, you may want to consider renaming it to phpdoc; we'll understand.

Then, all you need to do is run it!

Getting started using Docker

Use our very own Docker image; no installation needed!

Treat our docker image like you treat all your other utility images. Just don't forgot to volume mount your current directory to /data inside the container. Remember: No data, No docs.

$ docker run --rm -v ${PWD}:/data phpdoc/phpdoc:3

Tada!

phpDox is the documentation generator for PHP projects.
This includes, but is not limited to, API documentation.


By default, phpDox uses PHP-Parser to collect information about a PHP codebase. The information collected is stored in XML documents.

This information is rendered to HTML, for instance, by applying XSL transformations to the XML data.

Collect

Thanks to PHP-Parser, phpDox will always be able to parse PHP code that uses the latest syntax features of the language.

An API is provided to register custom or extended backends as well as additional DocBlock annotation parsers.

Enrich

The enricher subsystem of phpDox is based on plugins.

Writing enricher plugins is easy and allows phpDox to process additional information from new tools quickly.

Generate

The generator subsystem is based on plugins, so-called engines.

The default HTML engine uses XSLT stylesheets that ship with phpDox and can be adapted or replaced to customize the presentation of the information that is processed.


It's fast, too.

It takes 1.26 minutes (and 50 MB of memory) to process Zend Framework 2 on the first run.
And only 24.6 seconds (and 11.75 MB of memory) on subsequent runs.


For ActionScript 2, I've used NaturalDocs. However it has pretty poor support for PHP. I've looked so far at doxygen and phpDocumentor, but their output is pretty ugly in my opinion. Does anyone have any experience with automatic documentation generation for PHP? I'd prefer to be able to use javadoc-style tags, they are short to write and easy to remember.

albert

7,5983 gold badges18 silver badges31 bronze badges

asked Oct 9, 2008 at 22:55

0

ApiGen

http://apigen.org/

ApiGen has support for PHP 5.3 namespaces, packages, linking between documentation, cross referencing to PHP standard classes and general documentation, creation of highlighted source code and experimental support for PHP 5.4 traits.

DocBlox

http://www.docblox-project.org/

PHP 5.3 compatible API Documentation generator aimed at projects of all sizes and Continuous Integration.

able to fully parse and transform Zend Framework 2

answered Dec 31, 2011 at 19:35

3

There are two well-known and often-used tool that can generate API doc from docblocks :

  • phpDocumentor, which is specific to PHP, and is probably one of the most used tool for PHP projects
  • and Doxygen, which is more for C, but is used for PHP by some people.


About the "guidelines" : I would say it depends on your projects, but, at least, I would expect to see :

  • a description of what the method/function does
  • parameters, with @param type name description of the parameter
  • return value, with @return type description of the return value
  • exceptions, with @throws type description of the exception that can be thrown

A great thing being that recent IDE (like Eclipse PDT, for instance), can read and interpret those markers, to provide hints when you're coding ;-)


Also, there are more and more PHP tools that use php docblocks for some other purpose than documentation.

For instance, PHPUnit allows you to specify some test-related stuff using some specific tags -- see Annotations.

albert

7,5983 gold badges18 silver badges31 bronze badges

answered Dec 18, 2009 at 5:38

Pascal MARTINPascal MARTIN

388k77 gold badges646 silver badges656 bronze badges

1

PHPDoc is probably as good as you'll get it in terms of Javadoc style inline commenting. You might also want to look at PHPXRef.

answered Dec 18, 2009 at 5:39

3

Yes, phpDocumentor (http://www.phpdoc.org/) is an acceptable standard tool for PHP autodocs. It's the de-facto standard.

It's acceptable to follow the general JavaDoc guidelines for code when documenting PHP code. However, you're going to run into cases where that's not enough because PHP and Java are different languages.

For example, PHP functions have no return type and it's inevitable (and sometimes desirable) for a function to return one type with one context, and another type with in a second context. JavaDoc guidelines aren't going to help with that, because it's impossible to do in Java.

answered Dec 18, 2009 at 5:56

Alan StormAlan Storm

162k89 gold badges386 silver badges585 bronze badges

2

phpDocumentor can output in a style similar to the php.net documentation (and its built in with both smarty and non smarty layouts)

answered Oct 9, 2008 at 23:11

Generate php documentation from source code

Ólafur WaageÓlafur Waage

67.3k19 gold badges140 silver badges194 bronze badges

1

The Wordpress code-base is documented using phpdoc tags (see this) and it's generally pretty good - it's rendered here using phpDocumentor.

Most of the code that I write that's substantial enough that I need to think about autogenerating docs for is done in .Net, so I can't give much of a documentation writer's perspective though

answered Dec 18, 2009 at 5:41

coricori

8,4667 gold badges44 silver badges80 bronze badges

If ugly's a problem, I'd just switch the stylesheet for a custom one. If you don't want to overwrite the generated one, you can use a Firefox plugin like Stylish.

answered Oct 9, 2008 at 23:01

AupajoAupajo

5,7476 gold badges29 silver badges28 bronze badges

You could edit the template file to add your own stylesheet to override the existing one.

answered Oct 9, 2008 at 23:23

Darryl HeinDarryl Hein

140k89 gold badges213 silver badges259 bronze badges

Not the answer you're looking for? Browse other questions tagged php documentation documentation-generation or ask your own question.

How do I document PHP code?

Properly document PHP code.
Classes. Start every class with /** * Class description * * @author Your organization or personal name * @license MIT (or other licence) */.
Properties. Document every property with /** * Property brief description * * @var type */.
Methods. ... .

What is Inheritdoc PHP?

Description. The {@inheritdoc} inline tag is used in the class DocBlocks of child classes. phpDocumentor will automatically inherit the @author tag, @version tag, and @copyright tag from a parent class. {@inheritdoc} allows flexibility of where to put documentation from the parent class in a child class's documentation ...

What is PHPDoc in PhpStorm?

Using PHPDoc code inspections PhpStorm provides a set of predefined code inspections targeted at PHPDoc blocks. These inspections check whether classes, methods, functions, variables, and constants are supplied with a PHPDoc comment and whether the tags in the comment match the documented item.