+ * Determines the correct absolute path for the framework. A set of common
+ * paths is being tested (first most common for applications, second when
+ * core tests are being executed and third/forth if the framework has been
+ * cloned there).
+ *
+ * @return $frameworkPath Path for framework
+ */
+ public static final function detectFrameworkPath () {
+ // Is it not set?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::frameworkPath=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, self::$frameworkPath);
+ if (empty(self::$frameworkPath)) {
+ // Auto-detect core path (first application-common)
+ foreach (['core', self::getRootPath(), '/usr/local/share/php/core', '/usr/share/php/core'] as $possiblePath) {
+ // Create full path for testing
+ //* NOISY-DEBUG: */ printf('[%s:%d]: possiblePath=%s' . PHP_EOL, __METHOD__, __LINE__, $possiblePath);
+ $realPath = realpath($possiblePath);
+
+ // Is it false?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: realPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($realPath), $realPath);
+ if ($realPath === false) {
+ // Then, not found.
+ //* NOISY-DEBUG: */ printf('[%s:%d]: possiblePath=%s was not found. - SKIPPED!' . PHP_EOL, __METHOD__, __LINE__, $possiblePath);
+ continue;
+ }
+
+ // Append framework path
+ $frameworkPath = sprintf('%s%sframework%s', $realPath, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);
+
+ // First create full-qualified file name (FQFN) to framework/config-global.php
+ //* NOISY-DEBUG: */ printf('[%s:%d]: frameworkPath=%s' . PHP_EOL, __METHOD__, __LINE__, $frameworkPath);
+ $configFile = $frameworkPath . 'config-global.php';
+
+ // Is it readable?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: configFile=%s' . PHP_EOL, __METHOD__, __LINE__, $configFile);
+ if (is_readable($configFile)) {
+ // Found one
+ self::$frameworkPath = $frameworkPath;
+
+ // Abort here
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Setting self::frameworkPath=%s - BREAK!' . PHP_EOL, __METHOD__, __LINE__, $frameworkPath);
+ break;
+ }
+ }
+
+ // Able to find?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::frameworkPath=%s - Checking ...' . PHP_EOL, __METHOD__, __LINE__, self::$frameworkPath);
+ if (!is_dir(self::$frameworkPath)) {
+ // Is no directory
+ throw new Exception('Cannot find framework.');
+ }
+ }
+
+ // Return it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::frameworkPath=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, self::$frameworkPath);
+ return self::$frameworkPath;
+ }
+
+ /**
+ * Getter for root path
+ *
+ * @return $rootPath Root path
+ */
+ public static function getRootPath () {
+ // Get __DIR__, really simple and no detection
+ return __DIR__;
+ }
+
+ /**
+ * The framework's main entry point. This class isolates some local