forked from yiisoft/yii2-apidoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apidoc
executable file
·54 lines (50 loc) · 1.62 KB
/
apidoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env php
<?php
/**
* Yii Framework 2.0 API documentation generator
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
defined('YII_DEBUG') or define('YII_DEBUG', false);
$composerAutoload = [
__DIR__ . '/vendor/autoload.php', // standalone with "composer install" run
__DIR__ . '/../../autoload.php', // script is installed as a composer binary
__DIR__ . '/../../../../autoload.php', // script is run from yii2-dev/extensions
];
$vendorPath = null;
foreach ($composerAutoload as $autoload) {
if (file_exists($autoload)) {
require($autoload);
$vendorPath = dirname($autoload);
break;
}
}
$yiiDirs = [
__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
];
foreach ($yiiDirs as $dir) {
if (file_exists($dir . '/Yii.php')) {
require($dir . '/Yii.php');
break;
}
}
if (!class_exists('Yii')) {
echo PHP_EOL . "The Yii Framework 2.0 does not seem to be installed. Try running composer install." . PHP_EOL . PHP_EOL;
exit(1);
}
Yii::setAlias('@yii/apidoc', __DIR__);
$application = new yii\console\Application([
'id' => 'yii2-apidoc',
'basePath' => __DIR__,
'enableCoreCommands' => false,
'controllerNamespace' => 'yii\\apidoc\\commands',
]);
if ($vendorPath !== null) {
$application->setVendorPath($vendorPath);
}
$exitCode = $application->run();
exit($exitCode);