improved configuration loader, autoload is now compatible with windows
This commit is contained in:
parent
e458b72748
commit
b7a43145ca
|
@ -1,4 +1,4 @@
|
|||
php-vn-lib (2.1.4) stable; urgency=low
|
||||
php-vn-lib (2.1.5) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
16
lib/app.php
16
lib/app.php
|
@ -85,14 +85,18 @@ class App {
|
|||
*/
|
||||
function getConfigFile() {
|
||||
$configDir = _CONFIG_DIR .'/'. $this->name;
|
||||
$customFile = "$configDir/config.my.php";
|
||||
|
||||
if (file_exists('config.php'))
|
||||
$configFiles = [
|
||||
"$configDir/config.my.php",
|
||||
"$configDir/config.php",
|
||||
"config.my.php"
|
||||
];
|
||||
|
||||
foreach ($configFiles as $configFile)
|
||||
if (file_exists($configFile))
|
||||
return $configFile;
|
||||
|
||||
return 'config.php';
|
||||
else if (file_exists($customFile))
|
||||
return $customFile;
|
||||
else
|
||||
return "$configDir/config.php";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,7 @@ $vnAutoloadReplace = function($matches) {
|
|||
if (strlen($match) == 1)
|
||||
return $match;
|
||||
if ($match{0} == '\\')
|
||||
return DIRECTORY_SEPARATOR. $match{1};
|
||||
return '/'. $match{1};
|
||||
|
||||
return $match{0} .'-'. $match{1};
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ spl_autoload_register(function($className) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($classPath{0} != DIRECTORY_SEPARATOR)
|
||||
if ($classPath{0} != '/')
|
||||
$classPath = stream_resolve_include_path($classPath);
|
||||
|
||||
if (file_exists($classPath))
|
||||
|
|
Loading…
Reference in New Issue