PhpDocumentor 2 Installation and Generation of API Documents

  • 2021-06-28 09:03:19
  • OfStack

Official address: http://www.phpdoc.org/
Project address: https://github.com/phpDocumentor/phpDocumentor2

phpDocumentor 2 is a program that parses php source code and comment blocks and generates documents.

Inspired by phpdocumentor 1 and javadoc, it continues to innovate using a number of new technologies and supporting the new features of php.

Features of phpDocumentor 2:

Compatible with php5.3, full support for namespaces and closures.
Identify any tag supported, as well as some additional (such as @link).
Faster processing speed.The processing time of phpDocumentor 1 under Zend Framework was significantly reduced.
Low memory consumption, small, medium and large projects are less than 20MB, 40MB, and 100MB, respectively.
Incremental resolution.If you have an structure.xml file that you previously obtained by running phpdoc, you will be able to regenerate the document 80% faster with minor modifications.
It's easy to create a template with just one small step and three files to edit.
Compatible with generation 1 command line.For example--directory, --file and --target
Two-step processing.First generate the structure file, which you can use to format relevant information and display it with your own tools!

Installation requirements:

PHP 5.3.3 or higher
ext/iconv, http://php.net/manual/en/book.iconv.php (default from PHP version 5.0.0 on)
ext/intl, http://php.net/manual/en/book.intl.php
The XSL extension, http://www.php.net/manual/en/book.xsl.php (optional, only used when using xsl's templates)
Graphviz (optional, used to generate class diagrams)

Install phpDocumentor 2

1. Depends on pear for installation:

Download pear http://pear.php.net/go-pear.phar

Place go-pear.phar in the PHP directory

Execute the installation command:


php go-pear.phar

Input system is executed below

Then No. 1 Enter is installed

2. Next install the tools used for class diagram drawing:


pear install image_graphviz

Download http://www.graphviz.org/Download_windows.php graphviz-2.38.msi

After installation, note that the path to the bin has been added to the environment variable path.

Here's an important step: restart your computer or it won't work

3. Install phpDocumentor


pear channel-discover pear.phpdoc.org // register channel
pear remote-list -c phpdoc // List available versions 
pear install phpdoc/phpDocumentor // install phpDocumentor 

Detailed reference: http://pear.phpdoc.org/

Installation steps complete!

Prompt:

Both installed directories are under pear under PHP:

php/pear/PhpDocumentor
php/pear/Image

Using PhpDocumentor 2

Start building the project document below:

Under the PHP root directory:


phpdoc -d  Project absolute path  -t  Path to store generated documents 

d represents the path directory, t represents target.Or you can choose -f to specify a single file.Make a path and wait a few moments before you see the instructions in the target folder.

Example:


phpdoc -d E:\bak\video\code -t E:\bak\video\code\doc

Folder where E:\bakvideocode is the php code

E:bakvideocodedoc is the folder where the document was generated

Specific parameters are as follows:


project:run [-t|--target[="..."]] [-f|--filename[="..."]] [-d|--directory[="..."]] [-e|--extensions[="..."]] [-i|--ignore[="..."]] [--ignore-tags[="..."]] [--hidden] [--ignore-symlinks] [-m|--markers[="..."]] [--title[="..."]] [--force] [--validate] [--visibility[="..."]] [--defaultpackagename[="..."]] [--sourcecode] [-p|--progressbar] [--template[="..."]] [--parseprivate] [-c|--config[="..."]]


Related articles: