Abstract Class yii\apidoc\components\BaseController

Inheritanceyii\apidoc\components\BaseController » yii\console\Controller
Subclassesyii\apidoc\commands\ApiController, yii\apidoc\commands\GuideController
Available since extension's version2.0
Source Code https://github.com/yiisoft/yii2-apidoc/blob/master/components/BaseController.php

Command to render API Documentation files

Public Properties

Hide inherited properties

Property Type Description Defined By
$exclude string|array Files to exclude. yii\apidoc\components\BaseController
$pageTitle string Page title yii\apidoc\components\BaseController
$template string Template to use for rendering yii\apidoc\components\BaseController

Public Methods

Hide inherited methods

Method Description Defined By
options() yii\apidoc\components\BaseController

Property Details

Hide inherited properties

$exclude public property

Files to exclude.

public string|array $exclude null
$pageTitle public property

Page title

public string $pageTitle null
$template public property

Template to use for rendering

public string $template 'bootstrap'

Method Details

Hide inherited methods

findFiles() protected abstract method

Finds files

protected abstract array findFiles ( $dir, $except = [] )
$dir string

Directory to search files in.

$except array

List of names to exclude from search.

return array

Files found.

                abstract protected function findFiles($dir, $except = []);

findRenderer() protected abstract method

protected abstract yii\apidoc\renderers\BaseRenderer findRenderer ( $template )
$template string

                abstract protected function findRenderer($template);

loadContext() protected method

Loads context from cache

protected yii\apidoc\models\Context loadContext ( $location )
$location string

                protected function loadContext($location)
    $context = new Context();
    $cacheFile = $location . '/cache/apidoc.data';
    $this->stdout('Loading apidoc data from cache... ');
    if (file_exists($cacheFile)) {
        $context = unserialize(file_get_contents($cacheFile));
        $this->stdout('done.' . PHP_EOL, Console::FG_GREEN);
    } else {
        $this->stdout('no data available.' . PHP_EOL, Console::FG_YELLOW);
    return $context;

normalizeTargetDir() protected method

Checks that target directory is valid. Asks questions in tricky cases.

protected boolean|string normalizeTargetDir ( $target )
$target string

                protected function normalizeTargetDir($target)
    $target = rtrim(Yii::getAlias($target), '\\/');
    if (file_exists($target)) {
        if (is_dir($target) && !$this->confirm('TargetDirectory already exists. Overwrite?', true)) {
            $this->stderr('User aborted.' . PHP_EOL);
            return false;
        if (is_file($target)) {
            $this->stderr("Error: Target directory \"$target\" is a file!" . PHP_EOL);
            return false;
    } else {
        mkdir($target, 0777, true);
    return $target;

options() public method

public void options ( $actionID )

                public function options($actionID)
    return array_merge(parent::options($actionID), ['template', 'exclude', 'pageTitle']);

searchFiles() protected method

Finds files to process

protected array|boolean searchFiles ( $sourceDirs )
$sourceDirs array
return array|boolean

List of files to process or false on failure

                protected function searchFiles($sourceDirs)
    $this->stdout('Searching files to process... ');
    $files = [];
    if (is_array($this->exclude)) {
        $exclude = $this->exclude;
    } elseif (is_string($this->exclude)) {
        $exclude = explode(',', $this->exclude);
    } else {
        $exclude = [];
    foreach ($sourceDirs as $source) {
        foreach ($this->findFiles($source, $exclude) as $fileName) {
            $files[$fileName] = $fileName;
    $this->stdout('done.' . PHP_EOL, Console::FG_GREEN);
    if (empty($files)) {
        $this->stderr('Error: No files found to process.' . PHP_EOL);
        return false;
    return $files;

storeContext() protected method

Writes context into cache file

protected void storeContext ( $context, $location )
$context yii\apidoc\models\Context
$location string

                protected function storeContext($context, $location)
    $cacheFile = $location . '/cache/apidoc.data';
    if (!is_dir($dir = dirname($cacheFile))) {
        mkdir($dir, 0777, true);
    file_put_contents($cacheFile, serialize($context));

updateContext() protected method

protected void updateContext ( $context )
$context yii\apidoc\models\Context

                protected function updateContext($context)
    $this->stdout('Updating cross references and backlinks... ');
    $this->stdout('done.' . PHP_EOL, Console::FG_GREEN);