- if (empty(self::$corePath)) {
- // Auto-detect our core path
- self::$corePath = str_replace("\\", '/', dirname(__FILE__));
+ if (empty(self::$frameworkPath)) {
+ // Auto-detect core path (first application-common)
+ foreach (array('core', __DIR__, '/usr/local/share/php/core', '/usr/share/php/core') as $possiblePath) {
+ // Create full path for testing
+ $realPath = realpath($possiblePath);
+
+ // Debug message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: realPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($realPath), $realPath);
+
+ // Is it false?
+ if ($realPath === false) {
+ // Then, not found.
+ continue;
+ } // END - if
+
+ // 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
+ $configFile = $frameworkPath . 'config-global.php';
+
+ // Debug message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: configFile=%s' . PHP_EOL, __METHOD__, __LINE__, $configFile);
+
+ // Is it readable?
+ if (is_readable($configFile)) {
+ // Found one
+ self::$frameworkPath = $frameworkPath;
+
+ // Abort here
+ break;
+ } // END - if
+ } // END - foreach
+
+ // Able to find?
+ if (!is_dir(self::$frameworkPath)) {
+ // Is no directory
+ throw new Exception('Cannot find framework.');
+ } // END - if