/**
  * Initializes ApiGen environment.
  */
 public static function init()
 {
     // Safe locale and timezone
     setlocale(LC_ALL, 'C');
     if (!ini_get('date.timezone')) {
         date_default_timezone_set('UTC');
     }
     // Check required extensions
     foreach (array('json', 'iconv', 'mbstring', 'tokenizer') as $extension) {
         if (!extension_loaded($extension)) {
             throw new \Exception(sprintf("Required extension missing: %s\n", $extension), 1);
         }
     }
     if (static::isPearPackage()) {
         // PEAR package
         @(include 'Nette/loader.php');
         @(include 'Texy/texy.php');
     } elseif (static::isComposerPackage()) {
         // Composer package
         $vendorDir = realpath(static::getRootDir() . '/../..');
         @(include $vendorDir . '/nette/nette/Nette/loader.php');
         @(include $vendorDir . '/dg/texy/Texy/Texy.php');
         set_include_path($vendorDir . '/kukulich/fshl' . PATH_SEPARATOR . $vendorDir . '/andrewsville/php-token-reflection' . PATH_SEPARATOR . get_include_path());
     } elseif (static::isStandalonePackage() || static::isGitRepository()) {
         // Standalone package or Git repository
         $vendorDir = static::getRootDir() . '/vendor';
         @(include $vendorDir . '/Nette/Nette/loader.php');
         @(include $vendorDir . '/Texy/texy/texy.php');
         set_include_path($vendorDir . '/FSHL' . PATH_SEPARATOR . $vendorDir . '/TokenReflection' . PATH_SEPARATOR . get_include_path());
     } else {
         throw new Exception('Unsupported installation way', 2);
     }
     // Autoload
     spl_autoload_register(function ($className) {
         $className = trim($className, '\\');
         $classFileName = str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php';
         if (0 === strpos($className, 'ApiGen\\') && is_file($fileName = Environment::getRootDir() . DIRECTORY_SEPARATOR . $classFileName)) {
             include $fileName;
         } else {
             @(include $classFileName);
         }
     });
     // Check required libraries
     if (!class_exists('Nette\\Diagnostics\\Debugger')) {
         throw new \Exception('Could not find Nette framework', 3);
     }
     if (!class_exists('Texy')) {
         throw new \Exception('Could not find Texy! library', 3);
     }
     if (!class_exists('FSHL\\Highlighter')) {
         throw new \Exception('Could not find FSHL library', 3);
     }
     if (!class_exists('TokenReflection\\Broker')) {
         throw new \Exception('Could not find TokenReflection library', 3);
     }
 }
示例#2
0
 /**
  * @param $filename
  * @param $dir
  * @return string
  */
 public static function getPath($filename, $dir)
 {
     $path = Environment::getRootDir() . '/' . self::$storageDir . "/" . $dir . '/' . $filename;
     return $path;
 }