apidoc 1.62 KB
Newer Older
1 2 3 4
#!/usr/bin/env php
<?php
/**
 * Yii Framework 2.0 API documentation generator
Tobias Munk committed
5
 *
Tobias Munk committed
6
 * @link http://www.yiiframework.com/
7
 * @copyright Copyright (c) 2008 Yii Software LLC
Tobias Munk committed
8
 * @license http://www.yiiframework.com/license/
9 10
 */

11
defined('YII_DEBUG') or define('YII_DEBUG', false);
12 13

$composerAutoload = [
Tobias Munk committed
14 15
    __DIR__ . '/vendor/autoload.php', // standalone with "composer install" run
    __DIR__ . '/../../autoload.php', // script is installed as a composer binary
16
    __DIR__ . '/../../../../autoload.php', // script is run from yii2-dev/extensions
17
];
18
$vendorPath = null;
AlexGx committed
19
foreach ($composerAutoload as $autoload) {
Tobias Munk committed
20 21 22 23 24
    if (file_exists($autoload)) {
        require($autoload);
        $vendorPath = dirname($autoload);
        break;
    }
25 26
}
$yiiDirs = [
Tobias Munk committed
27 28 29
    __DIR__ . '/../../framework', // in yii2-dev repo
    __DIR__ . '/vendor/yiisoft/yii2', // standalone with "composer install" run
    __DIR__ . '/../../yiisoft/yii2', // script is installed as a composer binary
30
];
AlexGx committed
31
foreach ($yiiDirs as $dir) {
Tobias Munk committed
32 33 34 35
    if (file_exists($dir . '/Yii.php')) {
        require($dir . '/Yii.php');
        break;
    }
36 37
}
if (!class_exists('Yii')) {
Tobias Munk committed
38 39
    echo PHP_EOL . "The Yii Framework 2.0 does not seem to be installed. Try running composer install." . PHP_EOL . PHP_EOL;
    exit(1);
40 41 42 43 44
}

Yii::setAlias('@yii/apidoc', __DIR__);

$application = new yii\console\Application([
Tobias Munk committed
45 46 47 48
    'id'                  => 'yii2-apidoc',
    'basePath'            => __DIR__,
    'enableCoreCommands'  => false,
    'controllerNamespace' => 'yii\\apidoc\\commands',
49
]);
50
if ($vendorPath !== null) {
Tobias Munk committed
51
    $application->setVendorPath($vendorPath);
52
}
53 54
$exitCode = $application->run();
exit($exitCode);