improved configuration loader, autoload is now compatible with windows

This commit is contained in:
Juan 2018-06-06 13:11:06 +02:00
parent e458b72748
commit b7a43145ca
6 changed files with 19 additions and 15 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
php-vn-lib (2.1.4) stable; urgency=low
php-vn-lib (2.1.5) stable; urgency=low
* Initial Release.

View File

@ -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";
}
/**

View File

@ -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))