phpDocumentor学习使用记录
phpDocumentor学习使用记录
一.phpDocumentor简介
PHPDocumentor是一个用PHP写的工具,对于有规范注释的php程序,它能够快速生成具有相互参照,索引等功能的API文档。老的版本是phpdoc,从1.3.0开始,更名为phpDocumentor,新的版本加上了对php5语法的支持,同时,可以通过在客户端浏览器上操作生成文档,文档可以转换为PDF,HTML,CHM几种形式,非常的方便。
phpDocumentor是一个非常强大的文档自动生成工具,利用它可以帮助我们编写规范的注释,生成易于理解,结构清晰的文档,对我们的代码升级,维护,移交等都有非常大的帮助。
二.那些元素可以生成文档
Function 函数
Constant 常量
Class 类
Interface 接口
Trait 特性
Class constant 类常量
Property 属性
Method 方法
File 文件
include/require声明 包含文件声明
Variable 变量
三.基本格式
1.Summary 总结
2.Description 详细描述
3.Tags and annotations 标签和注释
Example:
/**
* 函数add,实现两个数的加法
*
* 一个简单的加法计算,函数接受两个数a、b,返回他们的和c
*
* @param int 加数
* @param int 被加数
* @return integer 返回值
*
*/
function Add($a, $b)
{
return $a+$b;
}
?>
用命令 phpdoc -d 项目绝对路径 -t 生成的文档存放的路径 生成文档
如下:
Add
integer Add( int $a, int $b)
[line 45]
函数add,实现两个数的加法
Constants 一个简单的加法计算,函数接受两个数a、b,返回他们的和c
Parameters
・ int $a - 加数
・ int $b - 被加数
四.标签详细list
Tag | Element | Description |
api | Method | 用来声明一个结构元素是否可被用作第三方API |
author | Any | 创建者信息 |
category | File、class | 文件或者类所属的目录 |
copyright | Any | 版权信息 |
deprecated | Any | 此tag将在将来的版本中被弃用 |
example | Any | 这个tag指明示例代码的路径 |
filesource | File | 源文件输出 |
global | Variable | 全局变量 |
ignore | Any | 这个标签不会包括在文档中 |
internal | Any | 这个标签仅在应用程序和内部库使用 |
license | File, Class | 文件和类的许可证信息 |
link | Any | 指明元素和网站的链接关系 |
method | Class | 指明类可用的魔术方法 |
package | File, Class | 文件和类所属的包信息 |
param | Method,Function | 方法和函数的参数信息 |
property | Class | 类的属性信息 |
property-read | Class | 类的只读属性信息 |
property-write | Class | 类的只写属性信息 |
return | Method,Function | 方法和函数的返回值 |
see | Any | 指明参考引用出处 |
since | Any | 元素从那个版本起用 |
source | Any, except File | 显示元素的源代码 |
subpackage | File, Class | 指明类和文件的子包 |
throws | Method,Function | 指明元素可能抛出的异常 |
todo | Any | 指明这个元素正在开发中 |
uses | Any | 指明元素引用的其他元素 |
var | Properties | 指明类的属性 |
version | Any | 指明当前元素的版本 |
五.类型
目前phpDocumentor中元素的各种标签需要和支持的各种类型。
1. 完整类名或者别名
使用它的完全限定类名(FQCN),这意味着类有一个前缀斜线,以表明它是类,如全名 \phpDocumentor\Descriptor\ClassDescriptor。
使用相对类名,例如 \Descriptor\ClassDescriptor。
用类的别名,例如 use phpDocumentorDescriptorParamDescriptor as Param
2. Php关键字
string
int or integer
float
bool or boolean
array
resource
null
callable
3. Phpdoc标准的关键字
mixed
void
object
false or true
self
static
$this
4. 联合类型
/** @return string|null */
六.运行phpDocumentor
Phpdoc
phpdoc run
phpdoc project:run
上面三个可以实现相同效果。
参数:
-d 项目源文件路径
-f 制定项目某一个文件
-t 生成文档的目录
phpdoc -d path/to/my/project -f path/to/an/additional/file -t path/to/my/output/folder
七.标签格式
1.@api
格式:@api
例如:
/**
*
* @api
*
*/
2. @author
格式:@author [name] [
例如:
/**
* @author My Name
* @author My Name <my.name@example.com>
*/
3. @category
格式:@category [description]
例如:
/**
* @category MyCategory
*/
4. @copyright
格式:@copyright [description]
例如:
/**
* @copyright 1997-2005 The PHP Group
*/
5. @deprecated
格式:@deprecated [
例如:
/**
* @deprecated
* @deprecated 1.0.0
* @deprecated No longer used by internal code and not recommended.
* @deprecated 1.0.0 No longer used by internal code and not recommended.
*/
6. @example
格式:@example [location] [
例如:
/**
* @example example1.php Counting in action.
* @example http://example.com/example2.phps Counting in action by a 3rd party.
* @example "My Own Example.php" My counting.
*/
7. @filesource
格式:@filesource
例如:
/**
* @filesource
*/
8. @global
格式:@global [Type] [name] @global [Type] [description]
例如:
/**
* @global string $user
* @global string username
*/
9. @ignore
格式:@ignore [
例如:
/**
* @ignore
*/
10. @internal
格式:@internal [description]
例如:
/**
* @internal
*/
11. @license
格式:@license [
例如:
/**
* @license GPL
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
12.@link
格式:@link [URI] [
{@link [URI] [
例如:
/**
* @link http://example.com/my/bar Documentation of Foo.
* When no more Foo ({@link http://example.com/my/bar}) are given
* this function will add one as there must always be one Foo.
*/
13. @method
格式:@method [return type] [name]([[type] [parameter]<, ...>]) [
例如:
/**
* @method string getString()
* @method void setInteger(integer $integer)
* @method setString(integer $integer)
*/
14. @package
格式:@package [level 1]\[level 2]\[etc.]
例如:
/**
* @package PSR\Documentation\API
*/
15. @param
格式:@param [Type] [name] [
例如:
/**
* @param mixed[] $items Array structure to count the elements of.
*/
16.@property
格式:@property [Type] [name] [
例如:
/**
* @property string $myProperty
*/
17. @property-read
格式:@property-read [Type] [name] [ 18. @property-write 格式:@property-write [Type] [name] [ 例如: 19.@return 格式:@return [Type] [ 例如: 20. @see 格式:@see [URI | FQSEN] [ 例如: 21. @since 格式:@since [version] [ 例如: 22. @source 格式:@source [ 例如: 23. @subpackage 格式:@subpackage [name] 例如: 24. @throws 格式:@throws [Type] [ 例如: 25. @todo 格式:@todo [description] 例如: 26. @uses 格式:@uses [FQSEN] [ 例如: 27. @var 格式:@var [“Type”] [$element_name] [ 例如: 28. @version 格式:@version [ 例如:
/**
* @property-read string $myProperty
*/
/**
* @property-write string $myProperty
*/
/**
* @return integer Indicates the number of items.
* @return string|null The label's text or null if none provided.
*/
/**
* @see http://example.com/my/bar Documentation of Foo.
* @see MyClass::$items For the property whose items are counted.
* @see MyClass::setItems() To set the items for this collection.
*/
/**
* @since 1.0.2 Added the $b argument.
* @since 1.0.1 Added the $a argument.
* @since 1.0.0
*
*/
function dump($a, $b)
{
<...>
}
/**
* @source 2 1 Check that ensures lazy counting.
*/
/**
* @package PSR
* @subpackage Documentation\API
*/
/**
* @throws InvalidArgumentException if the provided argument is not
* of type 'array'.
*/
/**
* @todo add an array parameter to count
*/
/**
* @uses MyClass::$items to retrieve the count from.
*/
/** @var string|null Should contain a description
* @var string $name Should contain a description
* @var string $description Should contain a description
*/
/**
* @version 1.0.1
* @version GIT: $Id$ In development. Very unstable.
*/

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











PHP 로깅은 웹 애플리케이션을 모니터링하고 디버깅하고 중요한 이벤트, 오류 및 런타임 동작을 캡처하는 데 필수적입니다. 시스템 성능에 대한 귀중한 통찰력을 제공하고 문제를 식별하며 더 빠른 문제 해결을 지원합니다.

Laravel은 직관적 인 플래시 방법을 사용하여 임시 세션 데이터 처리를 단순화합니다. 응용 프로그램에 간단한 메시지, 경고 또는 알림을 표시하는 데 적합합니다. 데이터는 기본적으로 후속 요청에만 지속됩니다. $ 요청-

PHP 클라이언트 URL (CURL) 확장자는 개발자를위한 강력한 도구이며 원격 서버 및 REST API와의 원활한 상호 작용을 가능하게합니다. PHP CURL은 존경받는 다중 프로모토콜 파일 전송 라이브러리 인 Libcurl을 활용하여 효율적인 execu를 용이하게합니다.

Laravel은 간결한 HTTP 응답 시뮬레이션 구문을 제공하여 HTTP 상호 작용 테스트를 단순화합니다. 이 접근법은 테스트 시뮬레이션을보다 직관적으로 만들면서 코드 중복성을 크게 줄입니다. 기본 구현은 다양한 응답 유형 단축키를 제공합니다. Illuminate \ support \ Facades \ http를 사용하십시오. http :: 가짜 ([ 'google.com'=> 'Hello World', 'github.com'=> [ 'foo'=> 'bar'], 'forge.laravel.com'=>

고객의 가장 긴급한 문제에 실시간 인스턴트 솔루션을 제공하고 싶습니까? 라이브 채팅을 통해 고객과 실시간 대화를 나누고 문제를 즉시 해결할 수 있습니다. 그것은 당신이 당신의 관습에 더 빠른 서비스를 제공 할 수 있도록합니다.

Alipay PHP ...

기사는 PHP 5.3에 도입 된 PHP의 LSB (Late STATIC BING)에 대해 논의하여 정적 방법의 런타임 해상도가보다 유연한 상속을 요구할 수있게한다. LSB의 실제 응용 프로그램 및 잠재적 성능

이 기사에서는 프레임 워크에 사용자 정의 기능 추가, 아키텍처 이해, 확장 지점 식별 및 통합 및 디버깅을위한 모범 사례에 중점을 둡니다.
