# API documentation generator for Yii 2
This extension provides an API documentation generator for the [Yii framework 2.0](http://www.yiiframework.com/).
For license information check the [LICENSE](https://github.com/yiisoft/yii2-apidoc/blob/master/LICENSE.md)-file.
[![Latest Stable Version](https://camo.githubusercontent.com/164bda703f0198437f1b609d046ef25f1524a44c/68747470733a2f2f706f7365722e707567782e6f72672f796969736f66742f796969322d617069646f632f762f737461626c652e706e67)](https://packagist.org/packages/yiisoft/yii2-apidoc) [![Total Downloads](https://camo.githubusercontent.com/cdf07c2224b6981f16efe7ec4bd27137909ca836/68747470733a2f2f706f7365722e707567782e6f72672f796969736f66742f796969322d617069646f632f646f776e6c6f6164732e706e67)](https://packagist.org/packages/yiisoft/yii2-apidoc)
## [](https://github.com/yiisoft/yii2-apidoc#installation)Installation
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
~~~
php composer.phar require --prefer-dist yiisoft/yii2-apidoc
~~~
or add
~~~
"yiisoft/yii2-apidoc": "~2.0.0"
~~~
to the require section of your composer.json.
## [](https://github.com/yiisoft/yii2-apidoc#usage)Usage
This extension offers two commands:
* `api` to generate class API documentation.
* `guide` to render nice HTML pages from markdown files such as the yii guide.
Simple usage for stand alone class documentation:
~~~
vendor/bin/apidoc api source/directory ./output
~~~
Simple usage for stand alone guide documentation:
~~~
vendor/bin/apidoc guide source/docs ./output
~~~
You can combine them to generate class API and guide documentation in one place:
~~~
# generate API docs
vendor/bin/apidoc api source/directory ./output
# generate the guide (order is important to allow the guide to link to the apidoc)
vendor/bin/apidoc guide source/docs ./output
~~~
By default the `bootstrap` template will be used. You can choose a different template with the `--template=name` parameter. Currently there is only the `bootstrap` template available.
You may also add the `yii\apidoc\commands\ApiController` and `GuideController` to your console application command map and run them inside of your applications console app.
### [](https://github.com/yiisoft/yii2-apidoc#advanced-usage)Advanced usage
The following script can be used to generate API documentation and guide in different directories and also multiple guides in different languages (like it is done on yiiframework.com):
~~~
#!/bin/sh
# set these paths to match your environment
YII_PATH=~/dev/yiisoft/yii2
APIDOC_PATH=~/dev/yiisoft/yii2/extensions/apidoc
OUTPUT=yii2docs
cd $APIDOC_PATH
./apidoc api $YII_PATH/framework/,$YII_PATH/extensions $OUTPUT/api --guide=../guide-en --guidePrefix= --interactive=0
./apidoc guide $YII_PATH/docs/guide $OUTPUT/guide-en --apiDocs=../api --guidePrefix= --interactive=0
./apidoc guide $YII_PATH/docs/guide-ru $OUTPUT/guide-ru --apiDocs=../api --guidePrefix= --interactive=0
# repeat the last line for more languages
~~~
### [](https://github.com/yiisoft/yii2-apidoc#creating-a-pdf-of-the-guide)Creating a PDF of the guide
You need `pdflatex` and GNU `make` for this.
~~~
vendor/bin/apidoc guide source/docs ./output --template=pdf
cd ./output
make pdf
~~~
If all runs without errors the PDF will be `guide.pdf` in the `output` dir.
## [](https://github.com/yiisoft/yii2-apidoc#special-markdown-syntax)Special Markdown Syntax
We have a special Syntax for linking to classes in the API documentation. See the [code style guide](https://github.com/yiisoft/yii2/blob/master/docs/internals/core-code-style.md#markdown) for details.
## [](https://github.com/yiisoft/yii2-apidoc#creating-your-own-templates)Creating your own templates
TDB
## [](https://github.com/yiisoft/yii2-apidoc#using-the-model-layer)Using the model layer
TDB
- 介绍(Introduction)
- 关于 Yii(About Yii)
- 从 Yii 1.1 升级(Upgrading from Version 1.1)
- 入门(Getting Started)
- 安装 Yii(Installing Yii)
- 运行应用(Running Applications)
- 第一次问候(Saying Hello)
- 使用 Forms(Working with Forms)
- 玩转 Databases(Working with Databases)
- 用 Gii 生成代码(Generating Code with Gii)
- 更上一层楼(Looking Ahead)
- 应用结构(Application Structure)
- 结构概述(Overview)
- 入口脚本(Entry Scripts)
- 应用(Applications)
- 应用组件(Application Components)
- 控制器(Controllers)
- 模型(Models)
- 视图(Views)
- 模块(Modules)
- 过滤器(Filters)
- 小部件(Widgets)
- 前端资源(Assets)
- 扩展(Extensions)
- 请求处理(Handling Requests)
- 运行概述(Overview)
- 引导(Bootstrapping)
- 路由引导与创建 URL(Routing and URL Creation)
- 请求(Requests)
- 响应(Responses)
- Sessions and Cookies
- 错误处理(Handling Errors)
- 日志(Logging)
- 关键概念(Key Concepts)
- 组件(Components)
- 属性(Properties)
- 事件(Events)
- 行为(Behaviors)
- 配置(Configurations)
- 别名(Aliases)
- 类自动加载(Class Autoloading)
- 服务定位器(Service Locator)
- 依赖注入容器(Dependency Injection Container)
- 配合数据库工作(Working with Databases)
- 数据库访问(Data Access Objects): 数据库连接、基本查询、事务和模式操作
- 查询生成器(Query Builder): 使用简单抽象层查询数据库
- 活动记录(Active Record): 活动记录对象关系映射(ORM),检索和操作记录、定义关联关系
- 数据库迁移(Migrations): 在团体开发中对你的数据库使用版本控制
- Sphinx
- Redis
- MongoDB
- ElasticSearch
- 接收用户数据(Getting Data from Users)
- 创建表单(Creating Forms)
- 输入验证(Validating Input)
- 文件上传(Uploading Files)
- 收集列表输入(Collecting Tabular Input)
- 多模型同时输入(Getting Data for Multiple Models)
- 显示数据(Displaying Data)
- 格式化输出数据(Data Formatting)
- 分页(Pagination)
- 排序(Sorting)
- 数据提供器(Data Providers)
- 数据小部件(Data Widgets)
- 操作客户端脚本(Working with Client Scripts)
- 主题(Theming)
- 安全(Security)
- 认证(Authentication)
- 授权(Authorization)
- 处理密码(Working with Passwords)
- 客户端认证(Auth Clients)
- 安全领域的最佳实践(Best Practices)
- 缓存(Caching)
- 概述(Overview)
- 数据缓存(Data Caching)
- 片段缓存(Fragment Caching)
- 分页缓存(Page Caching)
- HTTP 缓存(HTTP Caching)
- RESTful Web 服务
- 快速入门(Quick Start)
- 资源(Resources)
- 控制器(Controllers)
- 路由(Routing)
- 格式化响应(Response Formatting)
- 授权验证(Authentication)
- 速率限制(Rate Limiting)
- 版本化(Versioning)
- 错误处理(Error Handling)
- 开发工具(Development Tools)
- 调试工具栏和调试器(Debug Toolbar and Debugger)
- 使用 Gii 生成代码(Generating Code using Gii)
- TBD 生成 API 文档(Generating API Documentation)
- 测试(Testing)
- 概述(Overview)
- 搭建测试环境(Testing environment setup)
- 单元测试(Unit Tests)
- 功能测试(Functional Tests)
- 验收测试(Acceptance Tests)
- 测试夹具(Fixtures)
- 高级专题(Special Topics)
- 高级应用模版(Advanced Project Template)
- 从头构建自定义模版(Building Application from Scratch)
- 控制台命令(Console Commands)
- 核心验证器(Core Validators)
- 国际化(Internationalization)
- 收发邮件(Mailing)
- 性能优化(Performance Tuning)
- 共享主机环境(Shared Hosting Environment)
- 模板引擎(Template Engines)
- 集成第三方代码(Working with Third-Party Code)
- 小部件(Widgets)
- Bootstrap 小部件(Bootstrap Widgets)
- jQuery UI 小部件(jQuery UI Widgets)
- 助手类(Helpers)
- 助手一览(Overview)
- Array 助手(ArrayHelper)
- Html 助手(Html)
- Url 助手(Url)