diff --git a/crm/Core/PathManager.php b/crm/Core/PathManager.php index a86d9d2..9784cbd 100644 --- a/crm/Core/PathManager.php +++ b/crm/Core/PathManager.php @@ -54,20 +54,33 @@ class PathManager */ private static function findRootPath(): string { - // Force root path to be the directory containing the app folder - // This fixes the issue where composer.json exists in both root and app directories $currentPath = __DIR__; - - // Go up directories until we find the directory that contains both composer.json and app folder + while ($currentPath !== '/' && $currentPath !== '') { - if (file_exists($currentPath . '/composer.json') && is_dir($currentPath . '/app')) { + if (!file_exists($currentPath . '/composer.json')) { + $currentPath = dirname($currentPath); + continue; + } + + // Standard monorepo (CRM_Project): composer.json at repo root + app/ + if (is_dir($currentPath . '/app')) { return $currentPath; } + + // Standalone CRM clone (MoneyFlix): composer.json lives in crm/ with Modules/ + if (is_dir($currentPath . '/Modules')) { + $parentPath = dirname($currentPath); + if ($parentPath !== $currentPath && is_dir($parentPath . '/storage')) { + return $parentPath; + } + + return $currentPath; + } + $currentPath = dirname($currentPath); } - - // Fallback to current directory if composer.json not found - return dirname(__DIR__, 3); + + return dirname(__DIR__, 2); } /**