Skip to content

Commit

Permalink
Merge pull request #23 from jeffreyvr/main
Browse files Browse the repository at this point in the history
Look for valet site composer file
  • Loading branch information
freekmurze authored Jun 21, 2022
2 parents 5623db2 + b401e43 commit 899a615
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/scripts/global-ray-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down

0 comments on commit 899a615

Please sign in to comment.