本文整理汇总了PHP中Environment::getRootDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::getRootDir方法的具体用法?PHP Environment::getRootDir怎么用?PHP Environment::getRootDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::getRootDir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* 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: getPath
/**
* @param $filename
* @param $dir
* @return string
*/
public static function getPath($filename, $dir)
{
$path = Environment::getRootDir() . '/' . self::$storageDir . "/" . $dir . '/' . $filename;
return $path;
}