PHPackages                             yiisoft/yii2-apidoc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. yiisoft/yii2-apidoc

ActiveYii2-extension[Framework](/categories/framework)

yiisoft/yii2-apidoc
===================

API Documentation generator for the Yii framework 2.0

3.0.8(5mo ago)257701.8k↓29.3%119[5 issues](https://github.com/yiisoft/yii2-apidoc/issues)20BSD-3-ClauseHTMLPHP ^7.4 || ^8.0CI passing

Since Apr 13Pushed 2mo ago27 watchersCompare

[ Source](https://github.com/yiisoft/yii2-apidoc)[ Packagist](https://packagist.org/packages/yiisoft/yii2-apidoc)[ GitHub Sponsors](https://github.com/yiisoft)[ Fund](https://opencollective.com/yiisoft)[ RSS](/packages/yiisoft-yii2-apidoc/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (11)Versions (33)Used By (20)

 [ ![](https://avatars0.githubusercontent.com/u/993323) ](https://github.com/yiisoft)

API documentation generator
===========================

[](#api-documentation-generator)

This extension provides an API documentation generator.

For license information check the [LICENSE](LICENSE.md)-file.

[![Latest Stable Version](https://camo.githubusercontent.com/ec20075a6dbd496dfd6e4e91d82f4eb1c30a8785590d0730deacf8bd37a1e4fc/68747470733a2f2f706f7365722e707567782e6f72672f796969736f66742f796969322d617069646f632f762f737461626c652e706e67)](https://packagist.org/packages/yiisoft/yii2-apidoc)[![Total Downloads](https://camo.githubusercontent.com/18ae723036ed1976992fb05375a9152678fa2d3313c398d3f6fe8cb1eb0ff6bc/68747470733a2f2f706f7365722e707567782e6f72672f796969736f66742f796969322d617069646f632f646f776e6c6f6164732e706e67)](https://packagist.org/packages/yiisoft/yii2-apidoc)[![Build Status](https://github.com/yiisoft/yii2-apidoc/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-apidoc/actions)[![Static status](https://github.com/yiisoft/yii2-apidoc/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/yii2-apidoc/actions?query=workflow%3A%22static+analysis%22)[![Codecov](https://camo.githubusercontent.com/2c5d78b0ab197dad4537660681d1e60adfc440a6ebeebe77192765ed963bae6f/68747470733a2f2f636f6465636f762e696f2f67682f796969736f66742f796969322d617069646f632f67726170682f62616467652e737667)](https://codecov.io/gh/yiisoft/yii2-apidoc)

Installation
------------

[](#installation)

Important

- The minimum required [PHP](https://www.php.net/) version is PHP `8.2`.

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

Either run

```
composer require --prefer-dist yiisoft/yii2-apidoc:"~3.0.8"
```

The above command may not work on an existing project due to version conflicts that need to be resolved, so it is preferred to add the package manually to the `require` section of your composer.json:

```
"yiisoft/yii2-apidoc": "~3.0.8"
```

afterwards run `composer update`. You may also run `composer update yiisoft/yii2-apidoc cebe/markdown` if you want to avoid updating unrelated packages.

Usage
-----

[](#usage)

This extension creates executable at `/vendor/bin`. Please do change directory to that directory if you do not want to use full path i.e `/vendor/bin/apidoc` and use just the executable name as with below examples.

This extension offers two commands:

1)`api` to generate class API documentation. [phpDocumentor](https://www.phpdoc.org/) is used as a base framework so refer to its guide for the syntax.

The output of `help api` command (i.e `apidoc help api`):

```
DESCRIPTION

Renders API documentation files

USAGE

apidoc api   [...options...]

- sourceDirs (required): array

- targetDir (required): string

OPTIONS

--appconfig: string
  custom application configuration file path.
  If not set, default application configuration is used.

--color: boolean, 0 or 1
  whether to enable ANSI color in the output.
  If not set, ANSI color will only be enabled for terminals that support it.

--exclude: string|array
  files to exclude.

--guide: string
  url to where the guide files are located

--guide-prefix: string (defaults to 'guide-')
  prefix to prepend to all guide file names.

--help, -h: boolean, 0 or 1 (defaults to 0)
  whether to display help information about current command.

--interactive: boolean, 0 or 1 (defaults to 1)
  whether to run the command interactively.

--page-title: string

--repo-url: string
  Repository url (e.g. "https://github.com/yiisoft/yii2"). Optional, used for resolving relative links
  within a repository (e.g. "[docs/guide/README.md](docs/guide/README.md)"). If you don't have such links you can
  skip this. Otherwise, skipping this will cause generation of broken links because they will be not resolved and
  left as is.

--readme-url: string
  URL for the README to use for the index of the guide.

--silent-exit-on-exception: boolean, 0 or 1
  if true - script finish with `ExitCode::OK` in case of exception.
  false - `ExitCode::UNSPECIFIED_ERROR`.
  Default: `YII_ENV_TEST`

--template: string (defaults to 'bootstrap')
  template to use for rendering

```

2)`guide` to render nice HTML pages from markdown files such as the yii guide.

The output of `help guide` command (i.e `apidoc help guide`):

```
DESCRIPTION

Renders API documentation files

USAGE

apidoc guide   [...options...]

- sourceDirs (required): array

- targetDir (required): string

OPTIONS

--api-docs: string
  path or URL to the api docs to allow links to classes and properties/methods.

--appconfig: string
  custom application configuration file path.
  If not set, default application configuration is used.

--color: boolean, 0 or 1
  whether to enable ANSI color in the output.
  If not set, ANSI color will only be enabled for terminals that support it.

--exclude: string|array
  files to exclude.

--guide-prefix: string (defaults to 'guide-')
  prefix to prepend to all output file names generated for the guide.

--help, -h: boolean, 0 or 1 (defaults to 0)
  whether to display help information about current command.

--interactive: boolean, 0 or 1 (defaults to 1)
  whether to run the command interactively.

--page-title: string

--silent-exit-on-exception: boolean, 0 or 1
  if true - script finish with `ExitCode::OK` in case of exception.
  false - `ExitCode::UNSPECIFIED_ERROR`.
  Default: `YII_ENV_TEST`

--template: string (defaults to 'bootstrap')
  template to use for rendering

```

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
```

Note that in order to generate a proper index file, the `README.md` file containing links to guide sections must be present. An example of such file can be found in the [yii2 repository](https://raw.githubusercontent.com/yiisoft/yii2/master/docs/guide/README.md).

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 your application's console app.

### Generating docs from multiple sources

[](#generating-docs-from-multiple-sources)

The apidoc generator can use multiple directories, so you can generate docs for your application and include the yii framework docs to enable links between your classes and framework classes. This also allows `@inheritdoc` to work for your classes that extend from the framework. Use the following command to generate combined api docs:

```
./vendor/bin/apidoc api ./vendor/yiisoft/yii2,. docs/json --exclude="docs,vendor"
```

This will read the source files from `./vendor/yiisoft/yii2` directory and `.` which is the current directory (you may replace this with the location of your code if it is not in the current working directory).

### 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 --guide-prefix= --interactive=0
./apidoc guide $YII_PATH/docs/guide $OUTPUT/guide-en --apiDocs=../api --guide-prefix= --interactive=0
./apidoc guide $YII_PATH/docs/guide-ru $OUTPUT/guide-ru --apiDocs=../api --guide-prefix= --interactive=0
# repeat the last line for more languages
```

### Creating a PDF of the guide

[](#creating-a-pdf-of-the-guide)

Prerequisites:

- `pdflatex`.
- [Pygments](https://pygments.org/).
- GNU `make`.

Generation:

```
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.

Special Markdown Syntax
-----------------------

[](#special-markdown-syntax)

We have a special Syntax for linking to a class 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.

Generating documentation for your own project
---------------------------------------------

[](#generating-documentation-for-your-own-project)

To generate API documentation for your own project, use the "project" template and specify the README.md of your repository using the "readmeUrl" parameter:

```
apidoc api YOUR_REPO_PATH OUTPUT_PATH --exclude="vendor" --template="project" --readme-url="file://YOUR_REPO_PATH/README.md" --page-title="TITLE_OF_YOUR_DOCS"
```

To also include links to the Yii2 documentation, you can do:

```
apidoc api "YOUR_REPO_PATH,vendor/yiisoft/yii2" OUTPUT_PATH --exclude="vendor" --template="project" --readme-url="file://YOUR_REPO_PATH/README.md" --page-title="TITLE_OF_YOUR_DOCS"
```

Creating your own templates
---------------------------

[](#creating-your-own-templates)

TBD

Using the model layer
---------------------

[](#using-the-model-layer)

TBD

###  Health Score

68

—

FairBetter than 100% of packages

Maintenance79

Regular maintenance activity

Popularity57

Moderate usage in the ecosystem

Community47

Growing community involvement

Maturity79

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~163 days

Recently: every ~334 days

Total

27

Last Release

176d ago

Major Versions

2.1.6 → 3.0.x-dev2021-08-30

PHP version history (4 changes)2.1.0PHP &gt;=5.4

3.0.x-devPHP ^7.2

3.0.0PHP ^7.2 || ^8.0

3.0.8PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/261a6249c6f605f3956a2fae40fbb813f6b2e1e6f2bf806180c851a965426e54?d=identicon)[cebe](/maintainers/cebe)

![](https://www.gravatar.com/avatar/fc29e4e7068a00fe9b9db37b8aadda1db6020adcacef810461e47b99c2b150e6?d=identicon)[samdark](/maintainers/samdark)

![](https://www.gravatar.com/avatar/23416c58e0dce33a8369451a4ca0e28666373594027debc10184b37ade6a926b?d=identicon)[qiangxue](/maintainers/qiangxue)

---

Top Contributors

[![cebe](https://avatars.githubusercontent.com/u/189796?v=4)](https://github.com/cebe "cebe (195 commits)")[![samdark](https://avatars.githubusercontent.com/u/47294?v=4)](https://github.com/samdark "samdark (79 commits)")[![mspirkov](https://avatars.githubusercontent.com/u/63721828?v=4)](https://github.com/mspirkov "mspirkov (63 commits)")[![arogachev](https://avatars.githubusercontent.com/u/8326201?v=4)](https://github.com/arogachev "arogachev (43 commits)")[![qiangxue](https://avatars.githubusercontent.com/u/993322?v=4)](https://github.com/qiangxue "qiangxue (28 commits)")[![klimov-paul](https://avatars.githubusercontent.com/u/1482054?v=4)](https://github.com/klimov-paul "klimov-paul (11 commits)")[![Arhell](https://avatars.githubusercontent.com/u/26163841?v=4)](https://github.com/Arhell "Arhell (7 commits)")[![schmunk42](https://avatars.githubusercontent.com/u/649031?v=4)](https://github.com/schmunk42 "schmunk42 (6 commits)")[![mohorev](https://avatars.githubusercontent.com/u/4974062?v=4)](https://github.com/mohorev "mohorev (6 commits)")[![WinterSilence](https://avatars.githubusercontent.com/u/3521094?v=4)](https://github.com/WinterSilence "WinterSilence (3 commits)")[![brandonkelly](https://avatars.githubusercontent.com/u/47792?v=4)](https://github.com/brandonkelly "brandonkelly (3 commits)")[![lucianobaraglia](https://avatars.githubusercontent.com/u/374554?v=4)](https://github.com/lucianobaraglia "lucianobaraglia (3 commits)")[![machour](https://avatars.githubusercontent.com/u/304450?v=4)](https://github.com/machour "machour (3 commits)")[![rob006](https://avatars.githubusercontent.com/u/5972388?v=4)](https://github.com/rob006 "rob006 (2 commits)")[![SilverFire](https://avatars.githubusercontent.com/u/4499203?v=4)](https://github.com/SilverFire "SilverFire (2 commits)")[![tom--](https://avatars.githubusercontent.com/u/1178722?v=4)](https://github.com/tom-- "tom-- (2 commits)")[![jom](https://avatars.githubusercontent.com/u/68693?v=4)](https://github.com/jom "jom (1 commits)")[![jcherniak](https://avatars.githubusercontent.com/u/1727656?v=4)](https://github.com/jcherniak "jcherniak (1 commits)")[![mtangoo](https://avatars.githubusercontent.com/u/1502872?v=4)](https://github.com/mtangoo "mtangoo (1 commits)")[![nineinchnick](https://avatars.githubusercontent.com/u/795177?v=4)](https://github.com/nineinchnick "nineinchnick (1 commits)")

---

Tags

api-documentationdocumentationgeneratorhacktoberfestphpdocyiiyii2apiphpdocdocumentationyii2apidoc

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/yiisoft-yii2-apidoc/health.svg)

```
[![Health](https://phpackages.com/badges/yiisoft-yii2-apidoc/health.svg)](https://phpackages.com/packages/yiisoft-yii2-apidoc)
```

###  Alternatives

[phpdocumentor/phpdocumentor

Documentation Generator for PHP

4.4k3.1M878](/packages/phpdocumentor-phpdocumentor)[yiisoft/yii2-authclient

External authentication via OAuth and OpenID for the Yii framework

4676.2M179](/packages/yiisoft-yii2-authclient)[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k47](/packages/skeeks-cms)[yii2mod/yii2-cms

Yii2 CMS extension

439.3k2](/packages/yii2mod-yii2-cms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
