示例#1
0
 protected function getValidPaths($path)
 {
     if (is_array($path)) {
         $paths = [];
         foreach ($path as $unCheckedPath) {
             try {
                 $paths = array_merge($paths, self::$_instance->getValidPaths($unCheckedPath));
                 continue;
             } catch (FileNotFoundException $e) {
                 throw $e;
             }
         }
         return $paths;
     }
     // If `$path` is a directory
     if (is_dir($path)) {
         $paths = glob($path . '/*.*');
         if (empty($paths)) {
             throw new EmptyDirectoryException("Configuration directory: [{$path}] is empty");
         }
         return $paths;
     }
     // If `$path` is not a file, throw an exception
     if (is_file($path)) {
         return [$path];
     }
     $_includePaths = explode(PATH_SEPARATOR, get_include_path());
     $paths = [];
     foreach ($_includePaths as $_path) {
         $_file = $_path . DIRECTORY_SEPARATOR . $path;
         if (is_file($_file)) {
             $paths[] = $_file;
         }
     }
     if (empty($paths)) {
         throw new FileNotFoundException("Configuration file: [{$path}] cannot be found");
     }
     return $paths;
 }
示例#2
0
}
echo "INI: <br />";
$iniFile = __DIR__ . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'config.ini';
pre(\Configuration\Settings::load($iniFile));
echo "<br />";
echo "JSON: <br />";
$jsonFile = __DIR__ . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'config.json';
pre(\Configuration\Settings::load($jsonFile));
echo "<br />";
echo "PHP: <br />";
$phpFile = __DIR__ . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'config.php';
pre(\Configuration\Settings::load($phpFile));
echo "<br />";
echo "XML: <br />";
$xmlFile = __DIR__ . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'config.xml';
pre(\Configuration\Settings::load($xmlFile));
echo "<br />";
echo "[INI, PHP]: <br />";
pre(\Configuration\Settings::load([$iniFile, $phpFile]));
echo "<br />";
echo "[FOLDER]: <br />";
$folder = __DIR__ . DIRECTORY_SEPARATOR . 'files';
pre(\Configuration\Settings::load($folder));
echo "<br />";
echo "GET: <br />";
pre(\Configuration\Settings::get('php'));
echo "<br />";
pre(\Configuration\Settings::get('ini.app.timezone'));
echo "<br />";
pre(\Configuration\Settings::get('ini.app.host', 'localhost'));