mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 08:30:07 +01:00
#473 Add feature to load server environment variables from special file
This commit is contained in:
committed by
Matt Stauffer
parent
2568be3255
commit
8971bf8d6a
@@ -177,4 +177,28 @@ protected function isActualFile($path)
|
||||
{
|
||||
return ! is_dir($path) && file_exists($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load server environment variables if available.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @return void
|
||||
*/
|
||||
public function loadServerEnvironmentVariables($sitePath, $siteName)
|
||||
{
|
||||
$varFilePath = $sitePath . '/.valet-env.php';
|
||||
if (! file_exists($varFilePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$variables = include $varFilePath;
|
||||
if (! isset($variables[$siteName])) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($variables[$siteName] as $key => $value) {
|
||||
$_SERVER[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +135,13 @@ function valet_default_site_path($config)
|
||||
return $valetDriver->serveStaticFile($staticFilePath, $valetSitePath, $siteName, $uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to load server environment variables.
|
||||
*/
|
||||
$valetDriver->loadServerEnvironmentVariables(
|
||||
$valetSitePath, $siteName
|
||||
);
|
||||
|
||||
/**
|
||||
* Attempt to dispatch to a front controller.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user