diff --git a/src/scripts/global-ray-loader.php b/src/scripts/global-ray-loader.php index 7c4e238..b1358d9 100644 --- a/src/scripts/global-ray-loader.php +++ b/src/scripts/global-ray-loader.php @@ -12,7 +12,7 @@ class PharLoader { public static function load(string $pharPath, array $unlessDetectedPackages) { - $composerJson = getcwd() . '/composer.json'; + $composerJson = self::getComposerPath(); if (file_exists($composerJson)) { $composer = json_decode(file_get_contents($composerJson), true); @@ -36,6 +36,25 @@ public static function isRunningInLaravelAwareApp() return defined('STDIN') && strpos($_SERVER['argv'][0] ?? '', 'tinker.phar') !== false; } + + public static function getComposerPath() + { + $composerJson = getcwd() . '/composer.json'; + + if(strpos($composerJson, 'valet') !== false) { + $valetConfig = json_decode(file_get_contents($_SERVER['HOME'].'/.config/valet/config.json')); + + foreach($valetConfig->paths as $path) { + $composerPath = $path . '/' . str_replace('.' . $valetConfig->tld, '/', $_SERVER['HTTP_HOST']) . 'composer.json'; + + if(file_exists($composerPath)) { + return $composerPath; + } + } + } + + return $composerJson; + } } try {