arrow_back
Back

phpDocumentor: generate PHP API documentation from DocBlocks

Andrew Dorokhov Andrew Dorokhov schedule 1 min read
menu_book Table of Contents

Run phpDocumentor:

docker run --rm -v "$(pwd):/data" "phpdoc/phpdoc:3"

DocBlock

A DocBlock is a piece of documentation in your source code that informs you what the function of a certain class, method or other Structural Element is.

<?php
/**
 * This is a DocBlock.
 */
function associatedFunction() {
    // ...
}

File-level DocBlock:

<?php
   /**
    * I belong to a file
    */

   /**
    * I belong to a class
    */
   class Car {
        // ...
   }

DocBlocks are divided into three parts. Each of these parts is optional.

  • Summary.
  • Description.
  • Tags and annotations.
<?php
/**
 * A summary informing the user what the associated element does.
 *
 * A *description* to go _in-depth_ into the details of
 * this element and to provide some background information
 * or textual references.
 *
 * @param string $some_argument This description can span multiple lines.
 *
 * @return void
 */
 function my_function($some_argument) {
    // ...
 }
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

PHP_CodeSniffer (phpcs): coding standards and style checks

arrow_forward