1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-06 16:50:09 +01:00

Add the ability for drivers to check Composer dependencies (#1345)

This commit is contained in:
Matt Stauffer
2023-01-13 21:54:59 -05:00
committed by GitHub
parent 303462ffd1
commit 9143636c76
4 changed files with 32 additions and 19 deletions

View File

@@ -196,4 +196,20 @@ public function loadServerEnvironmentVariables(string $sitePath, string $siteNam
putenv($key.'='.$value);
}
}
public function composerRequires(string $sitePath, string $namespacedPackage): bool
{
if (! file_exists($sitePath.'/composer.json')) {
return false;
}
$composer_json_source = file_get_contents($sitePath.'/composer.json');
$composer_json = json_decode($composer_json_source, true);
if (json_last_error() !== JSON_ERROR_NONE) {
return false;
}
return isset($composer_json['require'][$namespacedPackage]);
}
}