phpDocumentor是一個產生PHP library 文件的工具(註解要按照PHPDoc格式來撰寫)

Pear 安裝

1pear channel-discover pear.phpdoc.org
2pear install phpdoc/phpDocumentor

composer 安裝(composer.json)

1{
2    "require-dev": {
3        "phpdocumentor/phpdocumentor": "2.*"
4    }
5}

指令及參數查詢

產生文件

1# -f file 代表要產生的輸入檔案
2# -d directory 代表要產生的輸入目錄
3# -t target 產生出來文件的目的路徑
4# --template 可以選擇輸出使用的template
5phpdoc -f <file_name> -t <path>
6phpdoc -d <dir_name> -t <path>
7phpdoc -d <dir_name> -t <path> --template="clean"

基本語法(可參考 文件)
範例

1<?php
2/**
3  * @package Vendor\Metadata
4  */
5namespace Vendor\Metadata;
6 
7/**
8  * Album meta class
9  * @example example.php How to use this class
10  */
11class Album
12{
13    /**
14      * @var integer album_id
15      */
16    private $album_id;
17 
18    /**
19      * Construct function
20      * @param integer $album_id
21      * @return void
22      */
23    public function __construct($album_id = 0)
24    {
25        $this->album_id = $album_id;
26    }
27}
Categories: PHP