apidoc 1.6 KB

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